60fps
This commit is contained in:
10
function.c
10
function.c
@@ -193,14 +193,12 @@ void inGameLoop (unsigned short int **tab2d, int N, vect *playerPos,
|
|||||||
time_t time_start = time(NULL) ;
|
time_t time_start = time(NULL) ;
|
||||||
time_t current_time = time(NULL);
|
time_t current_time = time(NULL);
|
||||||
time_t delay = 0;
|
time_t delay = 0;
|
||||||
char last = SDL_SCANCODE_1;
|
|
||||||
vect direction = { 0, 0 };
|
vect direction = { 0, 0 };
|
||||||
char input;
|
char input;
|
||||||
bool finish = false;
|
bool finish = false;
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
while (!finish)
|
while (!finish)
|
||||||
{
|
{
|
||||||
// printf ("Utilisez Z/Q/S/D pour bouger, X pour quitter : ");
|
|
||||||
SDL_PollEvent (&event);
|
SDL_PollEvent (&event);
|
||||||
|
|
||||||
if (event.type == SDL_KEYDOWN)
|
if (event.type == SDL_KEYDOWN)
|
||||||
@@ -230,11 +228,8 @@ void inGameLoop (unsigned short int **tab2d, int N, vect *playerPos,
|
|||||||
default:
|
default:
|
||||||
direction.x = 0;
|
direction.x = 0;
|
||||||
direction.y = 0;
|
direction.y = 0;
|
||||||
last = SDL_SCANCODE_F21;
|
|
||||||
}
|
}
|
||||||
if (last != input)
|
move (tab2d, playerPos, direction);
|
||||||
move (tab2d, playerPos, direction);
|
|
||||||
last = input;
|
|
||||||
if (isWin (tab2d, targets, nbr_targets))
|
if (isWin (tab2d, targets, nbr_targets))
|
||||||
{
|
{
|
||||||
puts ("Win!");
|
puts ("Win!");
|
||||||
@@ -247,7 +242,6 @@ void inGameLoop (unsigned short int **tab2d, int N, vect *playerPos,
|
|||||||
}
|
}
|
||||||
screenDisplayGameSDL (tab2d, display_user);
|
screenDisplayGameSDL (tab2d, display_user);
|
||||||
}
|
}
|
||||||
last = SDL_SCANCODE_F21;
|
|
||||||
current_time = time(NULL);
|
current_time = time(NULL);
|
||||||
if (current_time > delay)
|
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);
|
displayTextSDL(display_user, timeToText(time(NULL) - time_start), coor_time, size_time, 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDL_Delay(16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user