|
@@ -241,96 +241,51 @@ int main(int argc,char** argv)
|
|
|
interactions(player1,bullets,bombs,enemies,walls,powerups,rockets,boss1,score);
|
|
|
|
|
|
///////ENDGAME CHECKS
|
|
|
- if(boss1.health<1) //YOU WON!!
|
|
|
+ if(boss1.health<1 || gameover(player1,bombs))
|
|
|
{
|
|
|
/*if(sound){
|
|
|
pkill_music(thread[0]);
|
|
|
win_theme = pthread_create(&thread[2],NULL,pwin_theme,NULL);
|
|
|
}*/
|
|
|
-
|
|
|
- Victory(boss1.name,score,level,chflag);
|
|
|
-
|
|
|
+
|
|
|
WINDOW *replay;
|
|
|
-
|
|
|
- replay=newwin(3,25,26,20);
|
|
|
- box(replay,ACS_VLINE,ACS_HLINE);
|
|
|
-
|
|
|
- switch(playagain(replay)) // playagain() returns 'y', 'n' or 'q'
|
|
|
+ if(boss1.health<1) // YOU WON
|
|
|
{
|
|
|
- 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;
|
|
|
+ Victory(boss1.name,score,level,chflag);
|
|
|
+ replay=newwin(3,25,26,20);
|
|
|
+ } else // YOU LOST
|
|
|
+ {
|
|
|
+ Defeat(score);
|
|
|
+ replay=newwin(3,25,17,20);
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if(gameover(player1,bombs))
|
|
|
- {
|
|
|
- Defeat(score);
|
|
|
-
|
|
|
- WINDOW* replay;
|
|
|
-
|
|
|
- replay=newwin(3,25,17,20);
|
|
|
box(replay,ACS_VLINE,ACS_HLINE);
|
|
|
-
|
|
|
- switch(playagain(replay)) //playagain() returns 'y', 'n' or 'q'
|
|
|
+
|
|
|
+ switch(char choice = playagain(replay)) // playagain() returns 'y', 'n' or 'q'
|
|
|
{
|
|
|
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
|
|
|
+ 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
|
|
|
+ }
|
|
|
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;
|
|
|
+ continue; // Go to the beginning of the main loop
|
|
|
case 'q':
|
|
|
endwin();
|
|
|
cout<<lightgreen<<"Game exited correctly."<<none<<endl;
|
|
|
return 0;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
draw(player1,bullets,bombs,enemies,walls,powerups,rockets,boss1);
|
|
|
write_score(Score,score);
|
|
|
|