From 25b649e0936f753989f04a72bc309137069bf63f Mon Sep 17 00:00:00 2001 From: Gwyn Ciesla Date: Wed, 8 Aug 2012 06:49:01 -0500 Subject: [PATCH] Play again? --- NOTES | 1 - main.cpp | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++------- mishaps.cpp | 14 +++++++++++--- mishaps.h | 2 +- 4 files changed, 63 insertions(+), 12 deletions(-) diff --git a/NOTES b/NOTES index 4f0fc92..6ea47bb 100644 --- a/NOTES +++ b/NOTES @@ -1,2 +1 @@ Upload scores? -game over play again or quit dialogue. diff --git a/main.cpp b/main.cpp index bd41544..27444cd 100644 --- a/main.cpp +++ b/main.cpp @@ -63,7 +63,7 @@ int laser = 0; int missile = 0; int super_shield = 0; int sound = 1; - +int newgame = 0; int main(int argc, char *argv[]){ @@ -81,7 +81,7 @@ int main(int argc, char *argv[]){ game_object player; player.number = 1; player.active = 1; - player.x = 5; + player.x = 8; player.y = 35; player.direction = 5; player.face = 1; @@ -1313,7 +1313,7 @@ int main(int argc, char *argv[]){ //add to score score = score + 10; drawlocation = boom_object(drawlocation, boomstuff, player, boomsound, boomchannel); - life_loss(lives, score); + newgame = life_loss(lives, score); player = player_init(player); drawlocation = player.y-20; //kill any carried pods @@ -1350,7 +1350,7 @@ int main(int argc, char *argv[]){ //add to score score = score + 10; drawlocation = boom_object(drawlocation, boomstuff, player, boomsound, boomchannel); - life_loss(lives, score); + newgame = life_loss(lives, score); player = player_init(player); drawlocation = player.y-20; //kill any carried pods @@ -1387,7 +1387,7 @@ int main(int argc, char *argv[]){ //add to score score = score + 10; drawlocation = boom_object(drawlocation, boomstuff, player, boomsound, boomchannel); - life_loss(lives, score); + newgame = life_loss(lives, score); player = player_init(player); drawlocation = player.y-20; //kill any carried pods @@ -1421,7 +1421,7 @@ int main(int argc, char *argv[]){ //kill player only lives--; drawlocation = boom_object(drawlocation, boomstuff, player, boomsound, boomchannel); - life_loss(lives, score); + newgame = life_loss(lives, score); player = player_init(player); drawlocation = player.y-20; //kill any carried pods @@ -1520,7 +1520,7 @@ int main(int argc, char *argv[]){ lives--; landershot[landershotloop] = object_out(landershot[landershotloop]); drawlocation = boom_object(drawlocation, boomstuff, player, boomsound, boomchannel); - life_loss(lives, score); + newgame = life_loss(lives, score); player = player_init(player); drawlocation = player.y-20; //kill any carried pods @@ -1544,6 +1544,50 @@ int main(int argc, char *argv[]){ }; }; }; + + //start new game if applicable + if(newgame==1){ + halfdelay(1); + //Reset lives + lives = 4; + //Reset level + level = 1; + //Drop shields + shieldup = 0; + //Reactivate pods + for(int podloop = 0; podloop"); + strcpy (player.line1, "<_==>"); + //Bump shields + shieldsleft = 500; + //Smart bomb + smartbombs = 3; + //regen landers + int landerlimit = 0; + for(int landerloop = 0; landerloophscore){ mvprintw(11,20,"High Score: %s", outstring); }; pause_game = getch(); }; + if(pause_game=='n'){ endwin(); exit(0); + } else { + newgame = 1; + }; }; + + return newgame; } diff --git a/mishaps.h b/mishaps.h index a6b7257..074856c 100644 --- a/mishaps.h +++ b/mishaps.h @@ -1,3 +1,3 @@ game_object encrazify(game_object, game_object, Mix_Chunk*, int); int boom_object(int, game_object, game_object, Mix_Chunk*, int); -void life_loss(int, int); +int life_loss(int, int); -- 2.9.0