Browse Source

Add replay current level option to bossrush

I added the 'y'/'n'/'q' options at the end of the match also to
bossrush.
Matteo Zeccoli Marazzini 4 years ago
parent
commit
8a09d6151c
1 changed files with 72 additions and 45 deletions
  1. 72 45
      bossrush.cpp

+ 72 - 45
bossrush.cpp

@@ -268,32 +268,45 @@ int main(int argc,char** argv)
 			replay=newwin(3,25,26,20);
 			box(replay,ACS_VLINE,ACS_HLINE);
 			
-			if(playagain(replay))                           //playagain() returns true if player wants to play again, false otherwise
+			switch(playagain(replay))	// playagain() returns 'y'/'n'/'q'
 			{
-				delwin(replay);
-				timeout(500);
-				score=0;
-				erase();
-				refresh();
-				level = choose_level_bossrush(commands);
-				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;
-				if(level<3)
-					player1.weaponclass=2;
-				erase();
-				refresh();
-				continue;  
+				case 'y':
+					delwin(replay);
+					timeout(500);
+					score=0;
+					erase();
+					refresh();
+					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;
+					if(level<3)
+						player1.weaponclass=2;
+					erase();
+					refresh();
+					continue;
+				case 'n':
+					delwin(replay);
+					timeout(500);
+					score=0;
+					erase();
+					refresh();
+					level = choose_level_bossrush(commands);
+					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;
+					if(level<3)
+						player1.weaponclass=2;
+					erase();
+					refresh();
+					continue;
+				case 'q':
+					endwin();
+					cout<<lightgreen<<"Game exited correctly."<<none<<endl;
+					return 0;
 			}
-			else { 
-				endwin();
-				cout<<lightgreen<<"Game exited correctly."<<none<<endl;
-				return 0;
-			}	
 		}
-				
-			
+
 		if(gameover(player1,bombs))
 		{	
 			Defeat(score);
@@ -303,31 +316,45 @@ int main(int argc,char** argv)
 			replay=newwin(3,25,17,20);
 			box(replay,ACS_VLINE,ACS_HLINE);
 			
-			if(playagain(replay))                                        //playagain() returns true if player wants to play again, false otherwise
+			switch(playagain(replay))	// playagain() returns 'y'/'n'/'q'
 			{
-				delwin(replay);
-				timeout(500);
-				score=0;
-				erase();
-				refresh();
-				level = choose_level_bossrush(commands);
-				setup_level_bossrush(level, shootrate, refresh_time);
-				reset(player1, enemies, boss1, bullets, bombs, walls, powerups,rockets, level,chflag);       // reset box, player, enemy and delete all bullets and bombs
-				resetbosses(bosses,boss1,player1);
-				num=0;
-				if(level<3)
-					player1.weaponclass=2;
-				erase();
-				refresh();
-				continue;  
+				case 'y':
+					delwin(replay);
+					timeout(500);
+					score=0;
+					erase();
+					refresh();
+					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;
+					if(level<3)
+						player1.weaponclass=2;
+					erase();
+					refresh();
+					continue;
+				case 'n':
+					delwin(replay);
+					timeout(500);
+					score=0;
+					erase();
+					refresh();
+					level = choose_level_bossrush(commands);
+					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;
+					if(level<3)
+						player1.weaponclass=2;
+					erase();
+					refresh();
+					continue;
+				case 'q':
+					endwin();
+					cout<<lightgreen<<"Game exited correctly."<<none<<endl;
+					return 0;
 			}
-			else { 
-				endwin();
-				cout<<lightgreen<<"Game exited correctly."<<none<<endl;
-				return 0;
-			}		
 		}
-		
+
 		write_score(Score,score);
 	
 		if(boss1.alive){