Drawing 2026-09-20 14.39.01.excalidraw

⚠ Switch to EXCALIDRAW VIEW in the MORE OPTIONS menu of this document. ⚠ You can decompress Drawing data with the command palette: ‘Decompress current Excalidraw file’. For more info check in plugin settings under ‘Saving’

Excalidraw Data

Text Elements

int main

cout << "Starting the game..." << endl;
InitWindow(2 * offset + cellSize * cellCount, 2 * offset + cellSize * cellCount, "Retro Snake");
SetTargetFPS(60); ^IdAZ4a3C

    ClearBackground(green);
    DrawRectangleLinesEx(Rectangle{(float)offset - 5, (float)offset - 5, (float)cellSize * cellCount + 10, (float)cellSize * cellCount + 10}, 5, darkGreen);
    DrawText("Retro Snake", offset - 5, 20, 40, darkGreen);
    DrawText(TextFormat("%i", game.score), offset - 5, offset + cellSize * cellCount + 10, 40, darkGreen);
    game.Draw();

    EndDrawing();
}
CloseWindow();
return 0; ^0PYpEfim

while loop + movement

while (WindowShouldClose() == false) { BeginDrawing();

    if (EventTriggered(0.2))
    {
        allowMove = true;
        game.Update();
    }

    if (IsKeyPressed(KEY_UP) && game.snake.direction.y != 1 && allowMove)
    {
        game.snake.direction = {0, -1};
        game.running = true;
        allowMove = false;
    }
    if (IsKeyPressed(KEY_DOWN) && game.snake.direction.y != -1 && allowMove)
    {
        game.snake.direction = {0, 1};
        game.running = true;
        allowMove = false;
    }
    if (IsKeyPressed(KEY_LEFT) && game.snake.direction.x != 1 && allowMove)
    {
        game.snake.direction = {-1, 0};
        game.running = true;
        allowMove = false;
    }
    if (IsKeyPressed(KEY_RIGHT) && game.snake.direction.x != -1 && allowMove)
    {
        game.snake.direction = {1, 0};
        game.running = true;
        allowMove = false;
    }

we begin drawing if there is a keypress we start moving the snake

if key up and not going down we go down

if key down and not going up we go down

if left and not going tight we move left

if right and not going left we move left