57 lines
663 B
C
57 lines
663 B
C
#ifndef ENGINE_HPP
|
|
#define ENGINE_HPP
|
|
|
|
#include <stddef.h>
|
|
#define ROW 15
|
|
#define COL 21
|
|
|
|
typedef enum
|
|
{
|
|
UP,
|
|
DOWN,
|
|
LEFT,
|
|
RIGHT
|
|
} Direction;
|
|
|
|
typedef struct
|
|
{
|
|
int x, y;
|
|
} vec2;
|
|
|
|
int
|
|
equals(vec2* a, vec2* b);
|
|
|
|
void
|
|
set(vec2* vec2, int _x, int _y);
|
|
|
|
typedef struct
|
|
{
|
|
char view[ROW][COL];
|
|
int m_score, tail_size;
|
|
vec2 head, fruit, prev_head;
|
|
vec2 tail[(ROW * COL) - 1];
|
|
// vec2* tail[(ROW * COL) - 1];
|
|
Direction dir;
|
|
|
|
} Engine;
|
|
|
|
void
|
|
engine_init(Engine* engine);
|
|
|
|
void
|
|
engine_display(Engine* engine);
|
|
|
|
int
|
|
process_input(Direction* dir);
|
|
|
|
int
|
|
is_open(char* status, size_t len, Engine* engine);
|
|
|
|
void
|
|
eat(Engine* engine);
|
|
|
|
void
|
|
move(Engine *engine);
|
|
|
|
#endif
|