This commit is contained in:
2024-12-16 14:42:48 +01:00
parent 9c9ece6a79
commit ba61ae733b

View File

@@ -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);
}
}