Browse Source

Fix bug related to playing again after winning

If the user chose to play again at the current level (i.e. option 'y'),
the game level didn't get setup again. Because of this, the hp level of
the boss didn't get restored, causing the winning condition (boss hp <
1) to get triggered as soon as the match was started.
I made the setup_level() function get called even if the user doesn't
change the level.
Matteo Zeccoli Marazzini 4 years ago
parent
commit
5f06092537
2 changed files with 2 additions and 2 deletions
  1. 1 1
      bossrush.cpp
  2. 1 1
      invaders.cpp

+ 1 - 1
bossrush.cpp

@@ -285,8 +285,8 @@ int main(int argc,char** argv)
 					if(choice=='n')
 					{
 						level = choose_level_bossrush(commands);
-						setup_level_bossrush(level, shootrate, refresh_time);
 					}
+					setup_level_bossrush(level, shootrate, refresh_time);
 					reset(player1, enemies, boss1, bullets, bombs, walls, powerups,rockets, level,chflag); // reset box, player, enemy and deletes all bullets and bombs
 					resetbosses(bosses,boss1,player1);
 					num=0;

+ 1 - 1
invaders.cpp

@@ -272,8 +272,8 @@ int main(int argc,char** argv)
 					if(choice=='n')
 					{
 						level = choose_level(commands);     	// get desired level
-						setup_level(level, shootrate, refresh_time, boss1, ENEMY_NUM, commands);     	// set game parameters and boss
 					}
+					setup_level(level, shootrate, refresh_time, boss1, ENEMY_NUM, commands);     	// set game parameters and boss
 					load_enemies(enemies,ENEMY_NUM);
 					reset(player1, enemies, boss1, bullets, bombs, walls, powerups,rockets, level,chflag); // reset box, player, enemy and deletes all bullets and bombs
 					erase();