From 126b279afdb69361f506b992e81856932b327450 Mon Sep 17 00:00:00 2001 From: Jerry Aldrich Date: Wed, 8 Apr 2015 18:44:10 -0500 Subject: [PATCH] Set Game Over Window to quit on 'q' --- drawWindows.c | 32 +++++++++++++++++++------------- events.c | 4 ++-- initializeWorld.c | 4 +++- world.h | 2 +- 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/drawWindows.c b/drawWindows.c index b8ce094..9a90b0b 100644 --- a/drawWindows.c +++ b/drawWindows.c @@ -1,7 +1,7 @@ #include #include #include - +#include void drawScore(){ werase(scoreWin); box(scoreWin, 0, 0); @@ -12,18 +12,6 @@ void drawScore(){ 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(){ box(viewportWin,0,0); int i; @@ -43,3 +31,21 @@ void drawViewport(){ wnoutrefresh(viewportWin); 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(); +} diff --git a/events.c b/events.c index e95d503..f42a649 100644 --- a/events.c +++ b/events.c @@ -6,7 +6,7 @@ #include #include -int zombieModifer=0; +int zombieModifer=10; int itemModifier=0; void addItem(char *type, int yPos, int xPos){ @@ -29,7 +29,7 @@ void randomEvents(){ } if (eventTrigger < 10+zombieModifier){ struct OpenPos openPos = getOpenPos(); - addZombie(openPos.x, openPos.y); + addZombie(openPos.y, openPos.x); zombieModifier++; } if (eventTrigger==zombieModifier){ diff --git a/initializeWorld.c b/initializeWorld.c index a4aaba7..e7d69d2 100644 --- a/initializeWorld.c +++ b/initializeWorld.c @@ -3,6 +3,7 @@ #include #include #include +#include void initializeWorld() { struct Entity player = {.type="player",.symbol='@', .curYpos=1, .curXpos=1, .nextYpos=1, .nextXpos=1 ,.isAlive=1}; @@ -32,7 +33,8 @@ void initializeWorld() { drawViewport(); int i; for(i=0;i