wm.WILLIAM MARAISLet’s talk ↗
← All projects
GRAPHICS / RAYCASTING

C Game Engine.

An early game-engine experiment in C, built around a small tile map and a raycasting renderer. A top-down view makes the relationship between player position, ray intersections and wall projection visible.

STATUSGraphics prototype
TOOLS & TECHNOLOGIESC / SDL2 / SDL_image / Make

Projecting a 2D map

The renderer traces horizontal and vertical grid intersections and selects the nearer wall hit. Wall distance determines the height of a projected vertical strip; a cosine correction accounts for the angle between each ray and the player’s viewing direction.

Input and rendering

SDL2 handles keyboard events, texture loading and drawing. The prototype includes player movement, rotation, textured map geometry and a separate viewport for the projected scene.

A foundation in graphics programming

This is a learning prototype rather than a complete game engine. The project makes the core geometry of raycasting explicit and provides a foundation for later rendering and engine work.

EXPLORE THE SOURCE

Explore the implementation

View repository ↗
git clone https://github.com/SAED2906/C-Game-Engine.git

Code example

main.c — projection excerptC
float ca = pa-ra;
if (ca < 0) { ca += 2*PI; }
if (ca > 2*PI) { ca -= 2*PI; }

float line_heigth = (36*SCREEN_HEIGHT)/(dist1*cosf(ca));
if (line_heigth > SCREEN_HEIGHT) { line_heigth = SCREEN_HEIGHT; }

SDL_RenderSetScale(renderer, 15.0f, 1.0f);
float line = SCREEN_HEIGHT/2 - line_heigth/2;
SDL_RenderDrawLine(renderer, r, line, r, line_heigth+line);

NEXT PROJECTMOSS Utils ↗