From 7218a94130207c2410e0790308b315b2362921f8 Mon Sep 17 00:00:00 2001 From: suck5u <suck5u@etu.univ-lorraine.fr> Date: Sat, 2 Jan 2021 15:03:08 +0100 Subject: [PATCH] Optimisation --- code/round_management.c | 5 ++++- code/world_data.c | 20 ++++++++++---------- data/save.txt | 6 +++--- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/code/round_management.c b/code/round_management.c index 0a6b204..cd5d04d 100644 --- a/code/round_management.c +++ b/code/round_management.c @@ -38,7 +38,10 @@ void updateRound(round_t *round) if(round->counter == 0) { round->enemies[round->index_to_spawn].is_moving = 1; - round->index_to_spawn++; + if(round->index_to_spawn+1 < round->number_enemies) + { + round->index_to_spawn++; + } } round->counter++; if(round->counter == 50) diff --git a/code/world_data.c b/code/world_data.c index 6705436..8788201 100644 --- a/code/world_data.c +++ b/code/world_data.c @@ -87,8 +87,16 @@ void init_data(world_t *world) void refresh_data(world_t *world) { - //Si la manche n'est pas finie - if(isRoundEnded(&world->rounds) == 0) + //Si la manche est finie, manche suivante + if(isRoundEnded(&world->rounds) == 1) + { + //free(world->rounds.enemies); + nextRound(&world->rounds); + //printf("gg ta gagné"); + //Charger le bon nombre de texture + } + //Sinon si la manche n'est pas finie + else { updateRound(&world->rounds); for (int i = 0; i < world->rounds.number_enemies ; i++) @@ -104,14 +112,6 @@ void refresh_data(world_t *world) } } } - //Sinon si la manche est finie, manche suivante - else - { - //free(world->rounds.enemies); - nextRound(&world->rounds); - //printf("gg ta gagné"); - //Charger le bon nombre de texture - } //Les balles for(int i = 0; i < NB_BULLET; i++) diff --git a/data/save.txt b/data/save.txt index 95d1483..e9a03bd 100644 --- a/data/save.txt +++ b/data/save.txt @@ -1,8 +1,8 @@ /Vie du joueur au début -30 +10 /Nombre d'ennemis au début -6 +1 /Nombre d'ennemis en plus à chaque manche -3 +1 /Nombre de balles 30 -- GitLab