Set Game Over Window to quit on 'q'

main
Jerry Aldrich 11 years ago
parent e336a93c8d
commit 126b279afd
  1. 32
      drawWindows.c
  2. 4
      events.c
  3. 4
      initializeWorld.c
  4. 2
      world.h

@ -1,7 +1,7 @@
#include <world.h> #include <world.h>
#include <screen.h> #include <screen.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
void drawScore(){ void drawScore(){
werase(scoreWin); werase(scoreWin);
box(scoreWin, 0, 0); box(scoreWin, 0, 0);
@ -12,18 +12,6 @@ void drawScore(){
wnoutrefresh(scoreWin); wnoutrefresh(scoreWin);
} }
void drawGameOverWin(){
getmaxyx(stdscr,scrRows,scrCols);
gameOverWin=newwin(scrRows/2,scrCols/2,scrRows/4,scrCols/4);
nodelay(stdscr, FALSE);
box(gameOverWin,0,0);
wnoutrefresh(gameOverWin);
doupdate();
getch();
endwin();
exit(0);
}
void drawViewport(){ void drawViewport(){
box(viewportWin,0,0); box(viewportWin,0,0);
int i; int i;
@ -43,3 +31,21 @@ void drawViewport(){
wnoutrefresh(viewportWin); wnoutrefresh(viewportWin);
doupdate(); doupdate();
} }
void drawGameOverWin(){
getmaxyx(stdscr,scrRows,scrCols);
gameOverWin=newwin(scrRows/2,scrCols/2,scrRows/4,scrCols/4);
box(gameOverWin,0,0);
int gameOverWinRows, gameOverWinCols;
getmaxyx(gameOverWin,gameOverWinRows,gameOverWinCols);
mvwprintw(gameOverWin,1,(gameOverWinCols-strlen("GAME OVER"))/2,"%s","GAME OVER");
nodelay(stdscr, FALSE);
wnoutrefresh(gameOverWin);
doupdate();
char input = getch();
if (input == 'q' || input == 'Q'){
endwin();
exit(0);
}
drawGameOverWin();
}

@ -6,7 +6,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <zombies.h> #include <zombies.h>
int zombieModifer=0; int zombieModifer=10;
int itemModifier=0; int itemModifier=0;
void addItem(char *type, int yPos, int xPos){ void addItem(char *type, int yPos, int xPos){
@ -29,7 +29,7 @@ void randomEvents(){
} }
if (eventTrigger < 10+zombieModifier){ if (eventTrigger < 10+zombieModifier){
struct OpenPos openPos = getOpenPos(); struct OpenPos openPos = getOpenPos();
addZombie(openPos.x, openPos.y); addZombie(openPos.y, openPos.x);
zombieModifier++; zombieModifier++;
} }
if (eventTrigger==zombieModifier){ if (eventTrigger==zombieModifier){

@ -3,6 +3,7 @@
#include <ncurses.h> #include <ncurses.h>
#include <world.h> #include <world.h>
#include <screen.h> #include <screen.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};
@ -32,7 +33,8 @@ void initializeWorld() {
drawViewport(); drawViewport();
int i; int i;
for(i=0;i<INITIAL_SPAWN_NUM;i++){ for(i=0;i<INITIAL_SPAWN_NUM;i++){
addZombie(); struct OpenPos openPos = getOpenPos();
addZombie(openPos.y,openPos.x);
} }
} }

@ -13,7 +13,7 @@ struct Item allItems[MAX_ITEMS];
#define MAX_PROJECTILES 2 #define MAX_PROJECTILES 2
struct Projectile projectiles[MAX_PROJECTILES]; struct Projectile projectiles[MAX_PROJECTILES];
#define INITIAL_SPAWN_NUM 0 #define INITIAL_SPAWN_NUM 10
int zombieModifier; int zombieModifier;

Loading…
Cancel
Save