working reworked game

This commit is contained in:
2025-09-10 22:08:34 +03:00
parent 7498a49f88
commit ad5b8beb99
15 changed files with 416 additions and 144 deletions

13
src/food.c Normal file
View File

@@ -0,0 +1,13 @@
#include <stdlib.h>
#include "food.h"
#include "Board.h"
#include "BoardPiece.h"
#include "Snake.h"
void food_new_location(Board* board, BoardPiece* food, Snake* snake) {
do {
food->x = rand() % board->width;
food->y = rand() % board->height;
} while (food->x % 2 != 0 || snake_collides(snake, food));
}