@ -1,8 +1,9 @@
# include <world.h>
# include <initializeWorld.h>
# include <unistd.h>
# include <stdlib.h>
# include <string.h>
# include <weaponsSystem.h>
void updateViewportWin ( ) {
int i ;
for ( i = 0 ; i < MAX_ITEMS ; i + + ) {
@ -70,7 +71,6 @@ void updateInfoWin(){
mvwprintw ( infoWin , 1 , 7 , " Weapon: %s " , allEntities [ 0 ] . weapons [ allEntities [ 0 ] . curWeapon ] . type ) ;
mvwprintw ( infoWin , 2 , 9 , " 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 ( infoWin , 3 , 8 , " Bombs: 0 " ) ;
mvwaddch ( infoWin , 1 , 26 , ACS_ULCORNER ) ;
mvwaddch ( infoWin , 2 , 26 , ACS_VLINE ) ;
@ -161,6 +161,36 @@ void updateInfoWin(){
wnoutrefresh ( infoWin ) ;
}
void drawGameStartWin ( ) {
gameStartWin = newwin ( 11 , 39 , viewportWinRows / 4 , viewportWinCols / 4 ) ;
int gameStartWinRows , gameStartWinCols ;
getmaxyx ( gameStartWin , gameStartWinRows , gameStartWinCols ) ;
mvwprintw ( gameStartWin , 1 , ( gameStartWinCols - strlen ( " HOW TO PLAY " ) ) / 2 , " %s " , " HOW TO PLAY " ) ;
mvwprintw ( gameStartWin , 3 , 13 , " WASD | MOVE " ) ;
mvwprintw ( gameStartWin , 4 , 11 , " ARROWS | ATTACK " ) ;
mvwprintw ( gameStartWin , 5 , 13 , " 1234 | SELECT WEAPON " ) ;
mvwprintw ( gameStartWin , 6 , 16 , " R | RELOAD " ) ;
mvwprintw ( gameStartWin , 7 , 15 , " QE | USE ITEM " ) ;
mvwprintw ( gameStartWin , ( gameStartWinRows ) - 2 , ( gameStartWinCols - strlen ( " Press any key to start or 'q' to quit " ) ) / 2 , " %s " , " Press any key to start or 'q' to quit " ) ;
box ( gameStartWin , 0 , 0 ) ;
wnoutrefresh ( gameStartWin ) ;
doupdate ( ) ;
char input = wgetch ( gameStartWin ) ;
switch ( input ) {
case ' q ' :
case ' Q ' :
endwin ( ) ;
exit ( 0 ) ;
default :
nodelay ( stdscr , TRUE ) ;
return ;
}
}
void drawGameOverWin ( ) {
gameOverWin = newwin ( 11 , 39 , viewportWinRows / 4 , viewportWinCols / 4 ) ;
@ -169,16 +199,9 @@ void drawGameOverWin(){
mvwprintw ( gameOverWin , 1 , ( gameOverWinCols - strlen ( " GAME OVER " ) ) / 2 , " %s " , " GAME OVER " ) ;
mvwprintw ( gameOverWin , 3 , 5 , " Zombies Killed: %i " , allEntities [ 0 ] . killCount ) ;
mvwprintw ( gameOverWin , 4 , 8 , " Shots Fired: %i " , allEntities [ 0 ] . projectilesFired ) ;
if ( allEntities [ 0 ] . projectilesFired ! = 0 ) {
float hitPercent = ( ( ( float ) allEntities [ 0 ] . hitCount / ( float ) allEntities [ 0 ] . projectilesFired ) * 100 ) ;
mvwprintw ( gameOverWin , 5 , 11 , " Accuracy: %.0f%% " , hitPercent ) ;
}
else {
mvwprintw ( gameOverWin , 5 , 11 , " Accuracy: N/A " ) ;
}
int mins = secsElapsed / 60 ;
int secs = ( int ) secsElapsed % 60 ;
mvwprintw ( gameOverWin , 6 , 15 , " Time: %02d:%02d " , mins , secs ) ;
mvwprintw ( gameOverWin , 5 , 15 , " Time: %02d:%02d " , mins , secs ) ;
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 ) ;
box ( gameOverWin , 0 , 0 ) ;