Files
snake2025/grid.h

36 lines
656 B
C

#ifndef GRID_H
#define GRID_H
#include <stdio.h>
struct SnakeStruct;
struct GridStruct
{
char **grid;
int nbl;
int nbc;
};
typedef struct GridStruct Grid;
typedef enum
{
WALL = 'w',
EMPTY = ' ',
FRUIT = 'f',
SNAKE = 's'
} Element;
Grid* allocate_grid(int n, int m);
void free_grid(Grid *g);
void debug(Grid *g);
int compute_size(Grid *g, int w, int h);
void draw_grid(Grid *g);
void place_snake(Grid *g, struct SnakeStruct *snake);
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);
#endif /* GRID_H */