From 84f74de2988d7334ca162bff55a43decdbcfa2ee Mon Sep 17 00:00:00 2001 From: David Moeller Date: Mon, 5 Feb 2024 21:18:19 +0100 Subject: [PATCH] Snake adding Win and Lose Screen --- src/main/c/Snake/snake_start.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/c/Snake/snake_start.c b/src/main/c/Snake/snake_start.c index 2bbab0e..03323ce 100644 --- a/src/main/c/Snake/snake_start.c +++ b/src/main/c/Snake/snake_start.c @@ -77,12 +77,13 @@ void game_snake(){ while (running){ system("clear"); draw_snake(&snake, fruit); - if(check_if_dead(&snake)){break;} + if(check_if_dead(&snake)){printf("You Lose!"); getchar(); break;} t = clock() - t; 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);} + if(snake.length == WIDTH * HEIGHT){printf("You Win!"); running = false; getchar();} } }