|
@ -5,7 +5,7 @@ |
|
|
#include <stdlib.h> |
|
|
#include <stdlib.h> |
|
|
#include "snake_start.h" |
|
|
#include "snake_start.h" |
|
|
#include "get_character.h" |
|
|
#include "get_character.h" |
|
|
#define TIME_TURN 0.5 |
|
|
|
|
|
|
|
|
#define TIME_TURN 0.3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void main_menu(); |
|
|
void main_menu(); |
|
@ -17,6 +17,7 @@ void draw(Snake *snake, unsigned char fruit); |
|
|
int part_of_snake(Snake *snake, unsigned char tile); |
|
|
int part_of_snake(Snake *snake, unsigned char tile); |
|
|
bool check_if_dead(Snake *snake); |
|
|
bool check_if_dead(Snake *snake); |
|
|
unsigned char spawn_fruit(Snake *snake); |
|
|
unsigned char spawn_fruit(Snake *snake); |
|
|
|
|
|
unsigned char eating_fruit(Snake *snake); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void snake_start(){ |
|
|
void snake_start(){ |
|
@ -71,6 +72,7 @@ void game(){ |
|
|
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(); |
|
|
move_snake(&snake); |
|
|
move_snake(&snake); |
|
|
|
|
|
if(part_of_snake(&snake, fruit) == 0){fruit = eating_fruit(&snake);} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -180,4 +182,9 @@ unsigned char spawn_fruit(Snake *snake){ |
|
|
printf("%d\n", r); |
|
|
printf("%d\n", r); |
|
|
} |
|
|
} |
|
|
return r; |
|
|
return r; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
unsigned char eating_fruit(Snake *snake){ |
|
|
|
|
|
snake->length++; |
|
|
|
|
|
return spawn_fruit(snake); |
|
|
} |
|
|
} |