diff --git a/src/game.c b/src/game.c index 9212bdc495df3ea32a6e3c15df3747772e7f3f36..0391d0a4faeec09f652cbef2507f90a320c553af 100644 --- a/src/game.c +++ b/src/game.c @@ -28,7 +28,7 @@ void ResetGame(Snake *snake, Food *food, int *score, bool *gameOver) { *score = 0; *gameOver = false; } - +// if the game status is paused resume game and vice versa void TogglePause (GameState *state) { if (*state == PLAYING) { *state = PAUSED; @@ -37,7 +37,7 @@ void TogglePause (GameState *state) { } } - +// handle input for toggle pause, (activates the function) void HandlePauseInput(GameState * state) { if (IsKeyPressed(KEY_ESCAPE) || IsKeyPressed(KEY_P)) { TogglePause(state); diff --git a/src/obstacle.c b/src/obstacle.c index 9651a8058ea34b6c9d89627df2c4c53f44fc0e05..dd2026d6cc85ef2645191f87db1e6cd9b4db5aa0 100644 --- a/src/obstacle.c +++ b/src/obstacle.c @@ -54,7 +54,7 @@ void SpawnObstacle(Obstacle obstacles[], int count, const Snake *snake, const Fo } } } - +// renders obstacles as gray squares with an X detail. void DrawObstacles(const Obstacle obstacles[], int count) { for (int i = 0; i < MAX_OBSTACLES; i++) { if (obstacles[i].active) { @@ -76,9 +76,9 @@ void DrawObstacles(const Obstacle obstacles[], int count) { } } } - +// checks collision with obstacle, if snakes head x, y is in the same position as obstacle return True, if not return false. bool CheckObstacleCollision(const Snake *snake, const Obstacle obstacles[], int count) { - Position head = snake->segments[0]; // Use Position instead of Vector2 + Position head = snake->segments[0]; for (int i = 0; i < count; i++) { if (obstacles[i].active && head.x == obstacles[i].position.x &&