Added multi level support, dynamic snake location from level

This commit is contained in:
2025-05-27 11:50:20 +02:00
parent 4798ec85a3
commit c8a4a40618
11 changed files with 444 additions and 179 deletions

10
grid.h
View File

@@ -19,12 +19,14 @@ typedef enum
WALL = 'w',
EMPTY = ' ',
FRUIT = 'f',
SNAKE = 's'
SNAKE = 's',
SNAKEHEAD = 'S',
SNAKETAIL = 't'
} Element;
Grid* allocate_grid(int n, int m);
Grid *allocate_grid(int n, int m);
void free_grid(Grid *g);
void debug(Grid *g);
void debug_grid(Grid *g);
int compute_size(Grid *g, int w, int h);
void draw_grid(Grid *g);
void place_snake(Grid *g, struct SnakeStruct *snake);
@@ -32,5 +34,7 @@ Element move_snake(struct SnakeStruct *snake, Grid *g);
int count_nb_lines(FILE *stream);
int count_fruits(FILE *stream, Grid *g);
void copy(const char *src, char *dst);
int is_snake_connected(struct SnakeStruct *snake);
void read_snake_from_grid(Grid *g, struct SnakeStruct *snake);
#endif /* GRID_H */