From 8293ef57b828f366064d374c5a4286133636f5b7 Mon Sep 17 00:00:00 2001 From: "Ahmet Sungur (Student)" <ahmet2.sungur@live.uwe.ac.uk@csctcloud.prxhn32zsyjupl12zde3wlfkch.cwx.internal.cloudapp.net> Date: Thu, 3 Apr 2025 13:31:14 +0100 Subject: [PATCH] s --- src/game.c | 4 ++-- src/obstacle.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/game.c b/src/game.c index 9212bdc..0391d0a 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 9651a80..dd2026d 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 && -- GitLab