|
@ -77,12 +77,13 @@ void game_snake(){ |
|
|
while (running){ |
|
|
while (running){ |
|
|
system("clear"); |
|
|
system("clear"); |
|
|
draw_snake(&snake, fruit); |
|
|
draw_snake(&snake, fruit); |
|
|
if(check_if_dead(&snake)){break;} |
|
|
|
|
|
|
|
|
if(check_if_dead(&snake)){printf("You Lose!"); getchar(); 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(); |
|
|
move_snake(&snake); |
|
|
move_snake(&snake); |
|
|
if(part_of_snake(&snake, fruit) == 0){fruit = eating_fruit(&snake);} |
|
|
if(part_of_snake(&snake, fruit) == 0){fruit = eating_fruit(&snake);} |
|
|
|
|
|
if(snake.length == WIDTH * HEIGHT){printf("You Win!"); running = false; getchar();} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|