From ba61ae733bfcb724f87ac377d71302af844416c8 Mon Sep 17 00:00:00 2001 From: Aubin DORIVAL Date: Mon, 16 Dec 2024 14:42:48 +0100 Subject: [PATCH] 60fps --- function.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/function.c b/function.c index 7078c09..2df4ab6 100644 --- a/function.c +++ b/function.c @@ -193,14 +193,12 @@ void inGameLoop (unsigned short int **tab2d, int N, vect *playerPos, time_t time_start = time(NULL) ; time_t current_time = time(NULL); time_t delay = 0; - char last = SDL_SCANCODE_1; vect direction = { 0, 0 }; char input; bool finish = false; SDL_Event event; while (!finish) { - // printf ("Utilisez Z/Q/S/D pour bouger, X pour quitter : "); SDL_PollEvent (&event); if (event.type == SDL_KEYDOWN) @@ -230,11 +228,8 @@ void inGameLoop (unsigned short int **tab2d, int N, vect *playerPos, default: direction.x = 0; direction.y = 0; - last = SDL_SCANCODE_F21; } - if (last != input) - move (tab2d, playerPos, direction); - last = input; + move (tab2d, playerPos, direction); if (isWin (tab2d, targets, nbr_targets)) { puts ("Win!"); @@ -247,7 +242,6 @@ void inGameLoop (unsigned short int **tab2d, int N, vect *playerPos, } screenDisplayGameSDL (tab2d, display_user); } - last = SDL_SCANCODE_F21; current_time = time(NULL); if (current_time > delay) { @@ -255,7 +249,7 @@ void inGameLoop (unsigned short int **tab2d, int N, vect *playerPos, displayTextSDL(display_user, timeToText(time(NULL) - time_start), coor_time, size_time, 50); } - + SDL_Delay(16); } }