From c100e56944590985ed8ecbdcbc5f0d27b6542767 Mon Sep 17 00:00:00 2001 From: Matheus Date: Sun, 19 Oct 2025 14:52:49 -0300 Subject: feat:the game Kinda forgot commit. --- snake.h | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'snake.h') diff --git a/snake.h b/snake.h index e69de29..a7439bb 100644 --- a/snake.h +++ b/snake.h @@ -0,0 +1,54 @@ +#ifndef SNAKE_H +#define SNAKE_H + +#include +#include + +typedef enum Direction { + NORTH, + WEST, + EAST, + SOUTH +} Direction; + +typedef struct Point { + unsigned int x; + unsigned int y; +} Point; + +typedef struct PointList { + Point point; + struct PointList *next; +} PointList; + +typedef struct Snake { + PointList *head; + PointList *tail; + size_t length; + Direction moving_direction; +} Snake; + +typedef struct Map { + Point fruit; + Snake *snake; + bool fruit_eaten; + unsigned int height; + unsigned int width; +} Map; + +Snake *create_snake(unsigned int x, unsigned int y, Direction direction); + +Map *create_map(unsigned int width, unsigned int height); + +/* Attempts to move the snake. + * Returns true if the snake sucessfully moved, + * false for game over. + */ +bool move_snake(Map *map); + +/* Frees the snake */ +void free_snake(Snake *snake); + +void free_map(Map *map); + +#endif /* SNAKE_H */ -- cgit v1.2.3