diff --git a/src/main/c/Snake/snake_start.c b/src/main/c/Snake/snake_start.c index a56e34c..068eca7 100644 --- a/src/main/c/Snake/snake_start.c +++ b/src/main/c/Snake/snake_start.c @@ -5,7 +5,7 @@ #include #include "snake_start.h" #include "get_character.h" -#define TIME_TURN 0.5 +#define TIME_TURN 0.3 void main_menu(); @@ -17,6 +17,7 @@ void draw(Snake *snake, unsigned char fruit); int part_of_snake(Snake *snake, unsigned char tile); bool check_if_dead(Snake *snake); unsigned char spawn_fruit(Snake *snake); +unsigned char eating_fruit(Snake *snake); void snake_start(){ @@ -71,6 +72,7 @@ void game(){ get_next_move(TIME_TURN - (double)t / CLOCKS_PER_SEC, &snake, &running); t = clock(); 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); } return r; +} + +unsigned char eating_fruit(Snake *snake){ + snake->length++; + return spawn_fruit(snake); } \ No newline at end of file