serpent/serpent.h

51 lines
1.4 KiB
C
Raw Normal View History

#ifndef SERPENT_H
#define SERPENT_H
/* Program information */
#define NAME "serpent"
#define VERSION 0.1
/* */
2023-12-07 16:08:32 +00:00
/* Absolute value macro */
#define ABS(x) (x) < 0 ? -(x) : (x)
/* */
2023-12-07 23:33:25 +00:00
/* Global variables/constants */
#define START_SNAKE_SIZE 5 /* snake's initial size */
#define SNAKE_BODY '*' /* snake's body */
#define SNAKE_HEAD_U 'v' /* head when going up */
#define SNAKE_HEAD_D '^' /* head when going down */
#define SNAKE_HEAD_L '>' /* head when going left */
#define SNAKE_HEAD_R '<' /* head when going right */
#define FOOD '@' /* normal food */
#define SCREEN_WIDTH 50 /* the virtual screen width */
#define SCREEN_HEIGHT 20 /* the virtual screen height */
/* */
/* Possible directions for the snake */
typedef enum {
UP,
DOWN,
LEFT,
RIGHT
} Direction;
2023-12-07 23:33:25 +00:00
/* Snake node structure (for dobly linked list) */
typedef struct SnakeNode {
2023-12-07 23:33:25 +00:00
int pX, pY; /* represents the node's position on the board */
struct SnakeNode *next, *prev; /* pointers to the next and previous nodes */
} SnakeNode;
2023-12-07 23:33:25 +00:00
/* Snake structure (dobly linked list) */
typedef struct Snake {
Direction direction;
SnakeNode *head, *tail; /* snake's nodes, dobly linked list */
} Snake;
2023-12-07 23:33:25 +00:00
/* Apple structure */
typedef struct Food {
2023-12-09 00:18:52 +00:00
int pX, pY; /* represents the apple's position on the board */
} Apple;
#endif //SERPENT_H