Compare commits

...

5 Commits

  1. 2
      .gitignore
  2. 4
      collisionDetection.c
  3. 43
      drawWindows.c
  4. 9
      drawWindows.h
  5. 1
      events.c
  6. 1
      events.h
  7. 2
      gameLoop.c
  8. 6
      gameLoop.h
  9. 2
      getPos.c
  10. 3
      getPos.h
  11. 11
      initializeWorld.c
  12. 7
      initializeWorld.h
  13. 3
      nZombies.c
  14. 6
      nZombies.h
  15. 2
      weaponsSystem.c
  16. 1
      weaponsSystem.h
  17. 1
      world.h
  18. 3
      zombies.c

2
.gitignore vendored

@ -0,0 +1,2 @@
# Ignore nZombies binary
nZombies

@ -1,5 +1,9 @@
#include <world.h>
#include <string.h>
#include <drawWindows.h>
#include <weaponsSystem.h>
#include <unistd.h>
struct CollisionEvent collisionDetect(int objYpos, int objXpos){
int i;
for(i=1; i<MAX_ENTITIES; i++){

@ -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);

@ -0,0 +1,9 @@
#ifndef _DRAW_WINDOWS
#define _DRAW_WINDOWS
void updateViewportWin();
void updateInfoWin();
void drawGameStartWin();
void drawGameOverWin();
#endif

@ -4,6 +4,7 @@
#include <getPos.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
#include <zombies.h>
void addItem(char *type, int yPos, int xPos){

@ -3,4 +3,5 @@
void addItem(char *type, int yPos, int xPos);
void randomEvent();
void tryRandomEvent();
#endif

@ -3,6 +3,8 @@
#include <events.h>
#include <getPos.h>
#include <weaponsSystem.h>
#include <zombies.h>
#include <drawWindows.h>
void gameLoop(){
while(1) {

@ -0,0 +1,6 @@
#ifndef _GAME_LOOP
#define _GAME_LOOP
void gameLoop();
#endif

@ -1,5 +1,7 @@
#include <world.h>
#include <getPos.h>
#include <stdlib.h>
struct OpenPos getOpenPos(){
int chooseAnother=1;
struct OpenPos openPos;

@ -12,4 +12,7 @@ struct NextPos{
}nextPos;
struct OpenPos getOpenPos();
void getNextPos(int y, int x, int y2, int x2);
#endif

@ -3,12 +3,12 @@
#include <string.h>
#include <ncurses.h>
#include <world.h>
#include <drawWindows.h>
#include <zombies.h>
#include <nZombies.h>
#include <getPos.h>
void initializeWorld() {
startTime=clock();
timerStart=clock();
srand(time(NULL));
initscr();
@ -42,6 +42,8 @@ void initializeWorld() {
exit(0);
}
drawGameStartWin();
viewportWin=newwin(viewportWinRows,viewportWinCols,0,0);
infoWin=newwin(infoWinRows,infoWinCols,viewportWinRows,0);
@ -62,6 +64,9 @@ void initializeWorld() {
struct OpenPos openPos = getOpenPos();
addZombie(openPos.y,openPos.x);
}
startTime=clock();
timerStart=clock();
}
void restartGame(){

@ -0,0 +1,7 @@
#ifndef _EVENTS
#define _EVENTS
void initializeWorld();
void restartGame();
#endif

@ -1,4 +1,7 @@
#include <time.h>
#include <initializeWorld.h>
#include <gameLoop.h>
int main() {
initializeWorld();
gameLoop();

@ -0,0 +1,6 @@
#ifndef _N_Zombies
#define _N_Zombies
void main();
#endif

@ -1,6 +1,8 @@
#include <world.h>
#include <collisionDetection.h>
#include <weaponsSystem.h>
#include <string.h>
void moveProjectiles(){
int i;
for(i=0; i<MAX_PROJECTILES; i++){

@ -4,5 +4,6 @@
void moveProjectiles();
void fireWeapon();
void addMagazine();
void reload(struct Weapon *weaponRef);
#endif

@ -12,6 +12,7 @@ float secsElapsed;
WINDOW* viewportWin;
WINDOW* infoWin;
WINDOW* gameStartWin;
WINDOW* gameOverWin;
int stdscrRows,stdscrCols;

@ -1,6 +1,9 @@
#include <world.h>
#include <getPos.h>
#include <collisionDetection.h>
#include <stdlib.h>
#include <getPos.h>
void addZombie(int y, int x){
if (y && x){
int i;

Loading…
Cancel
Save