From 9c33a96b98398e19f8171f6eee335325dda35f7c Mon Sep 17 00:00:00 2001
From: suck5u <suck5u@etu.univ-lorraine.fr>
Date: Mon, 28 Dec 2020 21:26:11 +0100
Subject: [PATCH] Gestion des manches avec nombre d'ennemis dynamique

---
 code/display.c          |  7 +++++++
 code/round_management.c | 11 +++++++++--
 code/round_management.h |  1 +
 code/world_data.c       |  2 +-
 4 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/code/display.c b/code/display.c
index 457067f..0f4b22b 100644
--- a/code/display.c
+++ b/code/display.c
@@ -86,6 +86,13 @@ void refresh_graphics(SDL_Renderer *renderer, world_t *world,resources_t *resour
         SDL_RenderCopy(renderer, resources->bullet, NULL, &world->soldier.DestBullet[i]);
     }
     
+    if(world->rounds.is_new_round == 1)
+    {
+        clear_enemies_ressources(resources);
+        init_enemies_ressources(renderer,resources,world);
+        world->rounds.is_new_round = 0;
+    }
+
     //Les ennemis
     for (int i = 0; i < world->rounds.number_enemies; i++)
     {
diff --git a/code/round_management.c b/code/round_management.c
index 745cc90..c04d7f7 100644
--- a/code/round_management.c
+++ b/code/round_management.c
@@ -27,7 +27,6 @@ int isRoundEnded(round_t *round)
 }
 
 
-
 void initFirstRound(round_t *round, int nbEnemies, int incrementation)
 {
 	round->round_number = 0;
@@ -35,6 +34,7 @@ void initFirstRound(round_t *round, int nbEnemies, int incrementation)
 	round->incrementation = incrementation;
 	round->counter = 0;
 	round->index_to_spawn = 0;
+	round->is_new_round = 0;
 	createEnemies(round);
 }
 
@@ -55,7 +55,14 @@ void updateRound(round_t *round)
 
 void nextRound(round_t *round)
 {
-
+	clearEnemies(round);
+	round->round_number++;
+	printf("Manche %d\n",round->round_number);
+	round->number_enemies = round->number_enemies + round->incrementation;
+	round->index_to_spawn = 0;
+	round->counter = 0;
+	round->is_new_round = 1;
+	createEnemies(round);
 }
 
 //Créer nbEnemies
diff --git a/code/round_management.h b/code/round_management.h
index f764ef8..2c7766b 100644
--- a/code/round_management.h
+++ b/code/round_management.h
@@ -11,6 +11,7 @@ struct round_s
 	enemy_t *enemies;	//Tableau d'ennemis
 	int counter;		//Compteur entre chaque apparition des ennemis
 	int index_to_spawn;	//Index pour savoir quel ennemi doit apparaitre
+	int is_new_round;
 };
 /**
  * \brief Type qui correspond au round
diff --git a/code/world_data.c b/code/world_data.c
index b74126a..67a0687 100644
--- a/code/world_data.c
+++ b/code/world_data.c
@@ -24,7 +24,7 @@ void init_data(world_t *world)
 {
   
   //Chargement de la sauvegarde
-  int incrementation = 3;
+  int incrementation = 1;
   int nbEnemis = 4;
 
   //Chargement de la première manche
-- 
GitLab