diff --git a/code/display.c b/code/display.c index 0f57d82b61ebac6ef7dbf21d86cfddcebac5cc5c..6e0e2c419266a367d04508c80f7ad085b0188e00 100644 --- a/code/display.c +++ b/code/display.c @@ -102,14 +102,18 @@ void refresh_graphics(SDL_Renderer *renderer, world_t *world,resources_t *resour if (world->rounds.enemies[i].sprite.is_visible == 1) { - /*if(world->rounds.enemies[i].direction == 1) + if(world->rounds.enemies[i].direction == 1 && world->rounds.enemies[i].isLookingLeft == 1) { rotate_right(renderer, world, resources->enemies[i],i); + world->rounds.enemies[i].isLookingLeft = 0; + world->rounds.enemies[i].isLookingRight = 1; } - else + else if (world->rounds.enemies[i].direction == -1 && world->rounds.enemies[i].isLookingRight == 1) { rotate_left(renderer, world, resources->enemies[i],i); - }*/ + world->rounds.enemies[i].isLookingLeft = 1; + world->rounds.enemies[i].isLookingRight = 0; + } load_texture_enemies(resources, renderer, world, i); } } diff --git a/code/enemy.c b/code/enemy.c index 5af5b168e1cbbefd294d01a5a03d1cf07477df77..09c2c0548b30f82900c20f8fdefe1011d7a00c19 100644 --- a/code/enemy.c +++ b/code/enemy.c @@ -42,9 +42,13 @@ void init_enemyType1(enemy_t *enemy) { init_sprite(&enemy->sprite, SCREEN_WIDTH+75, SCREEN_HEIGHT-ENEMY_HEIGHT*2-20, ENEMY_WIDTH, ENEMY_HEIGHT, ENEMY_SPEED, 1); enemy->direction = -1; + enemy->isLookingRight = 0; + enemy->isLookingLeft = 1; }else{ init_sprite(&enemy->sprite, -75, SCREEN_HEIGHT-ENEMY_HEIGHT*2-20, ENEMY_WIDTH, ENEMY_HEIGHT, ENEMY_SPEED, 1); enemy->direction = 1; + enemy->isLookingRight = 1; + enemy->isLookingLeft = 0; } enemy->type = 1; enemy->DestEnemy.x = enemy->sprite.x; @@ -60,9 +64,13 @@ void init_enemyType2(enemy_t *enemy) { init_sprite(&enemy->sprite, SCREEN_WIDTH+75, SCREEN_HEIGHT-ENEMY_HEIGHT*2-20, ENEMY_WIDTH, ENEMY_HEIGHT, ENEMY_T2_SPEED, 2); enemy->direction = -1; + enemy->isLookingRight = 0; + enemy->isLookingLeft = 1; }else{ init_sprite(&enemy->sprite, -75, SCREEN_HEIGHT-ENEMY_HEIGHT*2-20, ENEMY_WIDTH, ENEMY_HEIGHT,ENEMY_T2_SPEED, 2); enemy->direction = 1; + enemy->isLookingRight = 1; + enemy->isLookingLeft = 0; } enemy->type = 2; enemy->DestEnemy.x = enemy->sprite.x; @@ -78,9 +86,13 @@ void init_enemyType3(enemy_t *enemy) { init_sprite(&enemy->sprite, SCREEN_WIDTH+75, SCREEN_HEIGHT-ENEMY_HEIGHT*2-20, ENEMY_WIDTH, ENEMY_HEIGHT, ENEMY_T3_SPEED, 1); enemy->direction = -1; + enemy->isLookingRight = 0; + enemy->isLookingLeft = 1; }else{ init_sprite(&enemy->sprite, -75, SCREEN_HEIGHT-ENEMY_HEIGHT*2-20, ENEMY_WIDTH, ENEMY_HEIGHT,ENEMY_T3_SPEED, 1); enemy->direction = 1; + enemy->isLookingRight = 1; + enemy->isLookingLeft = 0; } enemy->type = 3; enemy->DestEnemy.x = enemy->sprite.x; @@ -96,9 +108,13 @@ void init_enemyType4(enemy_t *enemy) { init_sprite(&enemy->sprite, SCREEN_WIDTH+75, SCREEN_HEIGHT-ENEMY_T4_HEIGHT*2-40, ENEMY_T4_WIDTH, ENEMY_T4_HEIGHT, 1, 1); enemy->direction = -1; + enemy->isLookingRight = 0; + enemy->isLookingLeft = 1; }else{ init_sprite(&enemy->sprite, -75, SCREEN_HEIGHT-ENEMY_T4_HEIGHT*2-40, ENEMY_T4_WIDTH, ENEMY_T4_HEIGHT,1, 1); enemy->direction = 1; + enemy->isLookingRight = 1; + enemy->isLookingLeft = 0; } enemy->type = 4; enemy->DestEnemy.x = enemy->sprite.x; diff --git a/code/enemy.h b/code/enemy.h index 5a584d12a5f03fb696f355f03300832790db7adc..256c6cdfddcc55f2d20f7dfc70329ddfee14d3d4 100644 --- a/code/enemy.h +++ b/code/enemy.h @@ -19,6 +19,8 @@ struct enemy_s{ int drop; powerUP_t powerUP; int direction; + int isLookingRight; + int isLookingLeft; }; /** * \brief Type qui correspond au paramètre du soldat diff --git a/code/world_data.c b/code/world_data.c index 878820162911223ef41b89b74bd2df21e9eff487..d19032a00bb3c42698268598c4ef423cafe7f204 100644 --- a/code/world_data.c +++ b/code/world_data.c @@ -90,10 +90,7 @@ void refresh_data(world_t *world) //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 diff --git a/data/save.txt b/data/save.txt index e9a03bdfced1713f9b6b517ab7e16a8c5e487287..5ef5d6d5e3c671f197778d80be91a99b0da6d396 100644 --- a/data/save.txt +++ b/data/save.txt @@ -1,7 +1,7 @@ /Vie du joueur au début 10 /Nombre d'ennemis au début -1 +5 /Nombre d'ennemis en plus à chaque manche 1 /Nombre de balles