-
Notifications
You must be signed in to change notification settings - Fork 0
/
snake.h
70 lines (61 loc) · 1.59 KB
/
snake.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*************************************************************************
*
* snake.h
*
* (c) 2021 J. G. Silva (django) <[email protected]>
*
* "Snake game written in C - animations, retro menu, smart snake
* enemies, sound effects."
*
* last modification: 2021-01-07
*
************************************************************************/
#ifndef SNAKE_H
#define SNAKE_H
/* Comprimento máximo permitido da cobrinha */
#define SNAKE_MAX_LENGTH 100
#include "map.h"
#include "food.h"
/* Modo de jogo da cobrinha */
typedef enum tagSnakeMode {
SNAKE_MODE_NORMAL,
SNAKE_MODE_ZOMBIE,
SNAKE_MODE_IMORTAL,
} SnakeMode;
/* Padrão de cores da cobrinha */
typedef enum tagColorPattern {
COLOR_PATTERN_AA,
COLOR_PATTERN_BB,
COLOR_PATTERN_AB,
COLOR_PATTERN_AAB,
COLOR_PATTERN_AAAB,
} ColorPattern;
/* Direções permitidas de movimento */
typedef enum tagDirection {
DIRECTION_UP,
DIRECTION_DOWN,
DIRECTION_RIGHT,
DIRECTION_LEFT
} Direction;
/* Cobrinha */
typedef struct tagSnake {
int x; // Coordenada X de referência
int y; // Coordenada Y de referência
Coord body[SNAKE_MAX_LENGTH];
int speed;
int length;
Direction dir;
SnakeMode mode;
int colorA; // cor primária
int colorB; // cor secundária
ColorPattern colorptrn; // padrão de cores
int lifes;
int score;
} Snake;
int snake_move(Snake *snake, Direction dir, Map *map);
int snake_movexy(Snake *snake, Coord newpos, Map *map);
void snake_draw(Snake *snake);
int snake_collide_self(Snake *snake);
int snake_collide_object(Snake *snake, Map *map);
int snake_collide_food(Snake *snake, Food *food);
#endif /* SNAKE_H */