Add restart option on Game Over

main
Jerry Aldrich 11 years ago
parent c24637f519
commit 93d0c12e4b
  1. 7
      drawWindows.c
  2. 14
      initializeWorld.c
  3. 4
      world.h

@ -10,6 +10,8 @@ void drawScore(){
mvwprintw(scoreWin, 2, 1, "Ammo: %d/%d:%d",allEntities[0].weapons[allEntities[0].curWeapon].curCapacity,allEntities[0].weapons[allEntities[0].curWeapon].maxCapacity,allEntities[0].weapons[allEntities[0].curWeapon].curMags); mvwprintw(scoreWin, 2, 1, "Ammo: %d/%d:%d",allEntities[0].weapons[allEntities[0].curWeapon].curCapacity,allEntities[0].weapons[allEntities[0].curWeapon].maxCapacity,allEntities[0].weapons[allEntities[0].curWeapon].curMags);
mvwprintw(scoreWin,3,1,"Zombies Killed: %d",allEntities[0].killCount); mvwprintw(scoreWin,3,1,"Zombies Killed: %d",allEntities[0].killCount);
mvwprintw(scoreWin,4,1,"Projectiles Fired: %d",allEntities[0].projectilesFired); mvwprintw(scoreWin,4,1,"Projectiles Fired: %d",allEntities[0].projectilesFired);
mvwprintw(scoreWin,5,1,"Zombies Modifier: %d",zombieModifier);
mvwprintw(scoreWin,6,1,"Item Modifier: %d",itemModifier);
wnoutrefresh(scoreWin); wnoutrefresh(scoreWin);
} }
@ -42,7 +44,7 @@ void drawGameOverWin(){
mvwprintw(gameOverWin,1,(gameOverWinCols-strlen("GAME OVER"))/2,"%s","GAME OVER"); mvwprintw(gameOverWin,1,(gameOverWinCols-strlen("GAME OVER"))/2,"%s","GAME OVER");
mvwprintw(gameOverWin,(gameOverWinRows/2)-1,1,"Shots Fired: %i",allEntities[0].projectilesFired); mvwprintw(gameOverWin,(gameOverWinRows/2)-1,1,"Shots Fired: %i",allEntities[0].projectilesFired);
mvwprintw(gameOverWin,(gameOverWinRows/2),1,"Zombies Killed: %i",allEntities[0].killCount); mvwprintw(gameOverWin,(gameOverWinRows/2),1,"Zombies Killed: %i",allEntities[0].killCount);
mvwprintw(gameOverWin,(gameOverWinRows)-2,(gameOverWinCols-strlen("Press 'q' to quit"))/2,"%s","Press 'q' to quit"); mvwprintw(gameOverWin,(gameOverWinRows)-2,(gameOverWinCols-strlen("Press 'q' to quit or 'r' to restart"))/2,"%s","Press 'q' to quit or 'r' to restart");
nodelay(stdscr, FALSE); nodelay(stdscr, FALSE);
wnoutrefresh(gameOverWin); wnoutrefresh(gameOverWin);
doupdate(); doupdate();
@ -52,5 +54,8 @@ void drawGameOverWin(){
endwin(); endwin();
exit(0); exit(0);
} }
if (input == 'r' || input == 'R'){
restartGame();
}
} }
} }

@ -6,6 +6,7 @@
#include <getPos.h> #include <getPos.h>
void initializeWorld() { void initializeWorld() {
struct Entity player = {.type="player",.symbol='@', .curYpos=1, .curXpos=1, .nextYpos=1, .nextXpos=1 ,.isAlive=1}; struct Entity player = {.type="player",.symbol='@', .curYpos=1, .curXpos=1, .nextYpos=1, .nextXpos=1 ,.isAlive=1};
struct Weapon pistol = {.type="Pistol", .isAlive=1, .range=3, .maxCapacity=12, .curCapacity=12, .symbols="-\\|/-\\|/"}; struct Weapon pistol = {.type="Pistol", .isAlive=1, .range=3, .maxCapacity=12, .curCapacity=12, .symbols="-\\|/-\\|/"};
@ -38,3 +39,16 @@ void initializeWorld() {
} }
} }
void restartGame(){
int i;
for(i=0;i<MAX_ENTITIES;i++){
allEntities[i].isAlive=0;
}
for(i=0;i<MAX_ITEMS;i++){
allItems[i].isAlive=0;
}
zombieModifier=0;
itemModifier=0;
endwin();
main();
}

@ -1,5 +1,5 @@
#ifndef _INITIALIZE_WORLD #ifndef _WORLD
#define _INITIALIZE_WORLD #define _WORLD
#define MAX_ENTITIES 10000 #define MAX_ENTITIES 10000
#define MAX_ITEMS 100 #define MAX_ITEMS 100

Loading…
Cancel
Save