From 416417da2290a1982d90cc6fbab046970c464100 Mon Sep 17 00:00:00 2001
From: belkhiritaha <belkhiri.taha53@gmail.com>
Date: Thu, 23 Jun 2022 09:50:37 +0200
Subject: [PATCH] ajout/affichage countdown

---
 travail_de_groupe/chef_oeuvre/src/fire.h   | 1 +
 travail_de_groupe/chef_oeuvre/src/render.c | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/travail_de_groupe/chef_oeuvre/src/fire.h b/travail_de_groupe/chef_oeuvre/src/fire.h
index 975fb32..84686a8 100644
--- a/travail_de_groupe/chef_oeuvre/src/fire.h
+++ b/travail_de_groupe/chef_oeuvre/src/fire.h
@@ -13,6 +13,7 @@
 #define STRONG 3
 #define SPREAD 4
 
+#define UPDATETIME 5
 
 
 typedef struct fire{
diff --git a/travail_de_groupe/chef_oeuvre/src/render.c b/travail_de_groupe/chef_oeuvre/src/render.c
index 93ec722..0bbc72f 100644
--- a/travail_de_groupe/chef_oeuvre/src/render.c
+++ b/travail_de_groupe/chef_oeuvre/src/render.c
@@ -266,7 +266,7 @@ void drawTime(){
     SDL_RenderCopy(renderer, scoreTexture, NULL, &rect);
     rect.y += rect.h;
     char str[10];
-    sprintf(str, "%d", (int)timer/1000);
+    sprintf(str, "%d", UPDATETIME - (int)timer/1000 % UPDATETIME);
     SDL_Color textColor = {237,222,17};
     SDL_Surface * surface = TTF_RenderText_Solid(robotoFont, str, textColor);
     SDL_Texture * texture = SDL_CreateTextureFromSurface(renderer, surface);
@@ -373,7 +373,7 @@ void mainLoop(){
                     drawMenu();
                     break;
                 case GAME:
-                    if ((int)timer/1000 % 5 == 0){
+                    if ((int)timer/1000 % UPDATETIME == 0){
                         nextFire(fireList);
                     }
                     drawGame();
-- 
GitLab