|
@@ -255,26 +255,37 @@ 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' or 'q'
|
|
|
{
|
|
|
- delwin(replay);
|
|
|
- timeout(500);
|
|
|
- score=0;
|
|
|
- erase();
|
|
|
- refresh();
|
|
|
- level = choose_level(commands); // get desired level
|
|
|
- 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();
|
|
|
- refresh();
|
|
|
- continue;
|
|
|
+ case 'y':
|
|
|
+ delwin(replay);
|
|
|
+ timeout(500);
|
|
|
+ score=0;
|
|
|
+ erase();
|
|
|
+ refresh();
|
|
|
+ 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();
|
|
|
+ refresh();
|
|
|
+ continue;
|
|
|
+ case 'n':
|
|
|
+ delwin(replay);
|
|
|
+ timeout(500);
|
|
|
+ score=0;
|
|
|
+ erase();
|
|
|
+ refresh();
|
|
|
+ level = choose_level(commands); // get desired level
|
|
|
+ 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();
|
|
|
+ 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;
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
|
|
@@ -287,25 +298,36 @@ 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' or 'q'
|
|
|
{
|
|
|
- delwin(replay);
|
|
|
- timeout(500);
|
|
|
- score=0;
|
|
|
- erase();
|
|
|
- refresh();
|
|
|
- level = choose_level(commands); // get desired level
|
|
|
- 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 delete all bullets and bombs
|
|
|
- erase();
|
|
|
- refresh();
|
|
|
- continue;
|
|
|
- }
|
|
|
- else {
|
|
|
- endwin();
|
|
|
- cout<<lightgreen<<"Game exited correctly."<<none<<endl;
|
|
|
- return 0;
|
|
|
+ case 'y':
|
|
|
+ delwin(replay);
|
|
|
+ timeout(500);
|
|
|
+ score=0;
|
|
|
+ erase();
|
|
|
+ refresh();
|
|
|
+ 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();
|
|
|
+ refresh();
|
|
|
+ continue;
|
|
|
+ case 'n':
|
|
|
+ delwin(replay);
|
|
|
+ timeout(500);
|
|
|
+ score=0;
|
|
|
+ erase();
|
|
|
+ refresh();
|
|
|
+ level = choose_level(commands); // get desired level
|
|
|
+ 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();
|
|
|
+ refresh();
|
|
|
+ continue;
|
|
|
+ case 'q':
|
|
|
+ endwin();
|
|
|
+ cout<<lightgreen<<"Game exited correctly."<<none<<endl;
|
|
|
+ return 0;
|
|
|
}
|
|
|
}
|
|
|
|