|
@ -1,21 +1,11 @@ |
|
|
#include <stdio.h> |
|
|
#include <stdio.h> |
|
|
#include <stdbool.h> |
|
|
#include <stdbool.h> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define HEIGHT 15 |
|
|
|
|
|
#define WIDTH 15 |
|
|
|
|
|
#define AREA HEIGHT * WIDTH |
|
|
|
|
|
|
|
|
|
|
|
typedef struct{ |
|
|
|
|
|
signed char direction[2]; |
|
|
|
|
|
char length; |
|
|
|
|
|
unsigned char segments[AREA]; |
|
|
|
|
|
}Snake; |
|
|
|
|
|
|
|
|
#include "snake_start.h" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void main_menu(); |
|
|
void main_menu(); |
|
|
void game(); |
|
|
void game(); |
|
|
Snake initialize_game(); |
|
|
|
|
|
|
|
|
Snake initialize_snake(); |
|
|
void draw(Snake *snake); |
|
|
void draw(Snake *snake); |
|
|
int part_of_snake(Snake *snake, unsigned char tile); |
|
|
int part_of_snake(Snake *snake, unsigned char tile); |
|
|
|
|
|
|
|
@ -55,7 +45,7 @@ void main_menu(){ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void game(){ |
|
|
void game(){ |
|
|
Snake snake = initialize_game(); |
|
|
|
|
|
|
|
|
Snake snake = initialize_snake(); |
|
|
bool running = true; |
|
|
bool running = true; |
|
|
while (running) |
|
|
while (running) |
|
|
{ |
|
|
{ |
|
@ -66,7 +56,7 @@ void game(){ |
|
|
getchar(); |
|
|
getchar(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Snake initialize_game(){ |
|
|
|
|
|
|
|
|
Snake initialize_snake(){ |
|
|
Snake snake = {{0, 1}, 3}; |
|
|
Snake snake = {{0, 1}, 3}; |
|
|
for(int i = 0; i < AREA; i++){ |
|
|
for(int i = 0; i < AREA; i++){ |
|
|
snake.segments[i] = 0; |
|
|
snake.segments[i] = 0; |
|
|