35 lines
503 B
C
35 lines
503 B
C
#ifndef SNAKE_H
|
|
#define SNAKE_H
|
|
|
|
struct GridStruct;
|
|
|
|
typedef struct Position
|
|
{
|
|
int x;
|
|
int y;
|
|
struct Position *next;
|
|
} Position;
|
|
|
|
typedef enum
|
|
{
|
|
TOP,
|
|
BOTTOM,
|
|
LEFT,
|
|
RIGHT
|
|
} Direction;
|
|
|
|
struct SnakeStruct
|
|
{
|
|
Position *segments_list;
|
|
int size;
|
|
Direction dir;
|
|
};
|
|
|
|
typedef struct SnakeStruct Snake;
|
|
|
|
Snake *new_snake(void);
|
|
void add_segment(Snake *snake, int x, int y);
|
|
void free_snake(Snake *snake);
|
|
void crawl(Snake *snake, struct GridStruct *g);
|
|
|
|
#endif /* SNAKE_H */ |