Skip to content
Snippets Groups Projects
Commit 9c33a96b authored by suck5u's avatar suck5u
Browse files

Gestion des manches avec nombre d'ennemis dynamique

parent 5fb0ae53
No related branches found
No related tags found
No related merge requests found
...@@ -86,6 +86,13 @@ void refresh_graphics(SDL_Renderer *renderer, world_t *world,resources_t *resour ...@@ -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]); 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 //Les ennemis
for (int i = 0; i < world->rounds.number_enemies; i++) for (int i = 0; i < world->rounds.number_enemies; i++)
{ {
......
...@@ -27,7 +27,6 @@ int isRoundEnded(round_t *round) ...@@ -27,7 +27,6 @@ int isRoundEnded(round_t *round)
} }
void initFirstRound(round_t *round, int nbEnemies, int incrementation) void initFirstRound(round_t *round, int nbEnemies, int incrementation)
{ {
round->round_number = 0; round->round_number = 0;
...@@ -35,6 +34,7 @@ void initFirstRound(round_t *round, int nbEnemies, int incrementation) ...@@ -35,6 +34,7 @@ void initFirstRound(round_t *round, int nbEnemies, int incrementation)
round->incrementation = incrementation; round->incrementation = incrementation;
round->counter = 0; round->counter = 0;
round->index_to_spawn = 0; round->index_to_spawn = 0;
round->is_new_round = 0;
createEnemies(round); createEnemies(round);
} }
...@@ -55,7 +55,14 @@ void updateRound(round_t *round) ...@@ -55,7 +55,14 @@ void updateRound(round_t *round)
void nextRound(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 //Créer nbEnemies
......
...@@ -11,6 +11,7 @@ struct round_s ...@@ -11,6 +11,7 @@ struct round_s
enemy_t *enemies; //Tableau d'ennemis enemy_t *enemies; //Tableau d'ennemis
int counter; //Compteur entre chaque apparition des ennemis int counter; //Compteur entre chaque apparition des ennemis
int index_to_spawn; //Index pour savoir quel ennemi doit apparaitre int index_to_spawn; //Index pour savoir quel ennemi doit apparaitre
int is_new_round;
}; };
/** /**
* \brief Type qui correspond au round * \brief Type qui correspond au round
......
...@@ -24,7 +24,7 @@ void init_data(world_t *world) ...@@ -24,7 +24,7 @@ void init_data(world_t *world)
{ {
//Chargement de la sauvegarde //Chargement de la sauvegarde
int incrementation = 3; int incrementation = 1;
int nbEnemis = 4; int nbEnemis = 4;
//Chargement de la première manche //Chargement de la première manche
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment