|
@ -6,6 +6,9 @@ |
|
|
#include "snake_start.h" |
|
|
#include "snake_start.h" |
|
|
#include "get_character.h" |
|
|
#include "get_character.h" |
|
|
#define TIME_TURN 0.3 |
|
|
#define TIME_TURN 0.3 |
|
|
|
|
|
#define START_LENGTH 3 |
|
|
|
|
|
#define START_DIRECTION 1 |
|
|
|
|
|
#define START_TILE 8 * 16 + 8 |
|
|
|
|
|
|
|
|
#pragma region Funktion_heads |
|
|
#pragma region Funktion_heads |
|
|
void main_menu(); |
|
|
void main_menu(); |
|
@ -63,11 +66,7 @@ void game(){ |
|
|
while (running){ |
|
|
while (running){ |
|
|
system("clear"); |
|
|
system("clear"); |
|
|
draw(&snake, fruit); |
|
|
draw(&snake, fruit); |
|
|
|
|
|
|
|
|
if(check_if_dead(&snake)){ |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(check_if_dead(&snake)){break;} |
|
|
t = clock() - t; |
|
|
t = clock() - t; |
|
|
get_next_move(TIME_TURN - (double)t / CLOCKS_PER_SEC, &snake, &running); |
|
|
get_next_move(TIME_TURN - (double)t / CLOCKS_PER_SEC, &snake, &running); |
|
|
t = clock(); |
|
|
t = clock(); |
|
@ -77,14 +76,12 @@ void game(){ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Snake initialize_snake(){ |
|
|
Snake initialize_snake(){ |
|
|
Snake snake = {1, 3}; |
|
|
|
|
|
for(int i = 0; i < AREA; i++){ |
|
|
|
|
|
snake.segments[i] = 0; |
|
|
|
|
|
|
|
|
Snake snake; |
|
|
|
|
|
snake.direction = START_DIRECTION; |
|
|
|
|
|
snake.length = START_LENGTH; |
|
|
|
|
|
for(int i = 0; i < START_LENGTH; i++){ |
|
|
|
|
|
snake.segments[i] = START_TILE - START_DIRECTION * i; |
|
|
} |
|
|
} |
|
|
snake.segments[0] = 8 + 16 * 8; |
|
|
|
|
|
snake.segments[1] = 7 + 16 * 8; |
|
|
|
|
|
snake.segments[2] = 6 + 16 * 8; |
|
|
|
|
|
|
|
|
|
|
|
return snake; |
|
|
return snake; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|