affichage score
This commit is contained in:
@@ -636,7 +636,7 @@ void nullScore(score *player_score)
|
||||
* \param display_user Tout les information du display de l'utilisateur utile.
|
||||
* \param win Si on veut un affichage de victoire ou non.
|
||||
*/
|
||||
void winOrLoseLoop(dis *display_user, bool win)
|
||||
void winOrLoseLoop(dis *display_user,score *score_user, bool win)
|
||||
{
|
||||
SDL_Surface *img;
|
||||
SDL_Texture *texture;
|
||||
@@ -648,6 +648,12 @@ void winOrLoseLoop(dis *display_user, bool win)
|
||||
|
||||
vect pos = {0, 0};
|
||||
displayImage(display_user->renderer, texture, pos, display_user->size_window);
|
||||
|
||||
char text[50] = "";
|
||||
snprintf(text, 50, "Score : %u",scoreCalculator(score_user, win));
|
||||
vect pos_score = {10, (display_user->size_window*3) / 4};
|
||||
vect size_score = {display_user->size_window / 4, display_user->size_window - 10};
|
||||
displayTextSDL(display_user, text , pos_score, size_score, 80);
|
||||
SDL_RenderPresent (display_user->renderer);
|
||||
|
||||
bool finish = false;
|
||||
@@ -659,8 +665,23 @@ void winOrLoseLoop(dis *display_user, bool win)
|
||||
if(event.type == SDL_KEYDOWN && event.key.keysym.scancode == SDL_SCANCODE_RETURN) finish = true;
|
||||
SDL_Delay(16);
|
||||
}
|
||||
|
||||
|
||||
|
||||
SDL_FreeSurface (img);
|
||||
SDL_DestroyTexture (texture);
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned int scoreCalculator(score *score_user, bool win)
|
||||
{
|
||||
unsigned short int result = 65535; //plus grand nombre
|
||||
int time = score_user->after - score_user->before;
|
||||
printf("%d\n", time);
|
||||
result -= (score_user->move_box + score_user->move_player) * time;
|
||||
if (!win)
|
||||
{
|
||||
result /= 50;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user