pvjc26/du4/game.h
2026-05-08 11:13:41 +02:00

37 lines
627 B
C

#ifndef snake_h_INCLUDED
#define snake_h_INCLUDED
#define FOOD_COUNT 20
struct snake {
int x;
int y;
struct snake* next;
};
enum endgame {
END_CONTINUE = 0,
END_WALL,
END_SNAKE,
END_FOOD,
END_USER
};
struct state {
struct snake* snake;
int foodx[FOOD_COUNT];
int foody[FOOD_COUNT];
int sx;
int sy;
int width;
int height;
};
struct snake* add_snake(struct snake* snake, int x, int y);
struct snake* remove_snake(struct snake* snake);
int is_snake(struct snake* snake, int x, int y);
void free_snake(struct snake* sn);
int step_state(struct state* state);
#endif