mirror of
https://github.com/BreizhHardware/bloubloulespoissons.git
synced 2026-01-18 16:47:31 +01:00
feat: ajout d'une fonctionnalité pour basculer l'affichage du FPS avec la touche F2
- Ajout d'une variable `std::atomic<bool> displayFPSFlag` pour suivre l'état d'affichage du FPS - Modification de la gestion des événements pour basculer `displayFPSFlag` lorsque la touche F2 est pressée - Mise à jour de la fonction `renderScene` pour afficher le FPS uniquement si `displayFPSFlag` est vrai
This commit is contained in:
@@ -43,6 +43,10 @@ void handleQuit() {
|
||||
Mix_VolumeMusic(MIX_MAX_VOLUME);
|
||||
}
|
||||
}
|
||||
|
||||
if (keystate[SDL_SCANCODE_F2]) {
|
||||
displayFPSFlag = !displayFPSFlag;
|
||||
}
|
||||
}
|
||||
|
||||
void cleanup() {
|
||||
|
||||
@@ -31,6 +31,7 @@ int SOUND_CHANNEL = 1;
|
||||
SDL_Texture* playerTexture = nullptr;
|
||||
SDL_Texture* fishTextures[100];
|
||||
std::vector<Fish> school;
|
||||
std::atomic<bool> displayFPSFlag(true);
|
||||
|
||||
|
||||
void resetAll(){
|
||||
|
||||
@@ -49,6 +49,7 @@ extern int SOUND_CHANNEL;
|
||||
extern SDL_Texture* fishTextures[100];
|
||||
extern SDL_Texture* playerTexture;
|
||||
extern std::vector<Fish> school;
|
||||
extern std::atomic<bool> displayFPSFlag;
|
||||
|
||||
bool initEnvironment(SDL_Renderer* renderer);
|
||||
std::vector<SDL_Texture*> initTexture(SDL_Renderer* renderer);
|
||||
|
||||
@@ -233,7 +233,9 @@ void renderScene(std::vector<Player>& players, const std::vector<Kelp>& kelps, c
|
||||
|
||||
shark.draw(renderer);
|
||||
|
||||
displayFPS(renderer, font, fps);
|
||||
if (displayFPSFlag) {
|
||||
displayFPS(renderer, font, fps);
|
||||
}
|
||||
|
||||
SDL_RenderPresent(renderer);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user