1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
|
#include<iostream>
#include<fstream>
#include<cstdlib>
#include<ctime>
#include<cctype>
using std::cout;
using std::cin;
using std::endl;
using std::fstream;
//gameArray indicies
//gameArray[0] = players current room
const int CURRENT_ROOM_INDEX = 0;
//gameArray[1] = current room of zombie
const int ZOMBIE_ROOM_INDEX = 1;
//gameArray[2]
const int NUM_BULLETS_INDEX = 2;
//gameArray[3]
const int NUM_ROOMS_INDEX = 3;
//boolean whether player has grail or not
const int HAVE_GRAIL_INDEX = 4;
//roomArray indices
//roomArray[gameArray[CURRENT_ROOM_INDEX]][4] = 1 or 0 if the player is
//or is not in the current room
const int PLAYER_INDEX = 4;
//roomArray[gameArray[ZOMBIE_ROOM_INDEX]][5] = 1, tracks where the zombie is
const int ZOMBIE_INDEX = 5;
//roomArray[room][6] = the room that the grail is in should be marked 1, all others 0
const int GRAIL_INDEX = 6;
// the number of rooms and number of bullets to fend off the zombies
const int MAX_ROOMS = 11;
const int MAX_BULLETS = 6;
//********************************************************************************************************************************************
//PART 1A prototypes
//reset simply resets the primary game variables
void reset(int ¤tRoom, int &zombieRoom, int &numBullets, int &numRooms, bool &haveGrail);
//print game instructions
void instructions();
//print layout of game memory
void printMemory(int gameArray[5], roomArray[][7]); //It's saying there's an error with my roomArray parameter! That doesn't make sense!
// the menu (which calls functions printMemory and instructions)
bool menu(int ¤tRoom, int &zombieRoom, int &numBullets, int &numRooms, bool &haveGrail, int gameArray[],int roomArray[][7]);
//********************************************************************************************************************************************
/*
//PART 1B prototypes
//read in the input file for the map
void readMaze(int roomArray[][7], int gameArray[5]);
//return a random room
int getRandomRoom(int gameArray[5]);
//place the zombie
void placeZombie(int roomArray[][7], int gameArray[5]);
//place the grail
void placeGrail(int roomArray[][7], int gameArray[5]);
// the setup function
void setup(int ¤tRoom, int &zombieRoom, int &numBullets, int &numRooms, bool &haveGrail, int roomArray[][7], int gameArray[5]);
//*********************************************************************************************************************************************
*/
//PART 2 prototypes
//PART 3 prototypes
int main()
{
// these variables are passed throughout this program
int roomArray[MAX_ROOMS][7],
gameArray[5],
currentRoom = 0,
zombieRoom = 0,
numBullets = 0,
numRooms = 0;
bool haveGrail = false;
reset(currentRoom, zombieRoom, numBullets, numRooms, haveGrail);
do
{
menu(currentRoom, zombieRoom, numBullets, numRooms, haveGrail, gameArray, roomArray);
} while (menu);
return 0;
}
// build your functions here. Don't forget your pre and post conditions
//pre: no preconditions
//post: resets primary game variables
void reset(int ¤tRoom, int &zombieRoom, int &numBullets, int &numRooms, bool &haveGrail)
{
currentRoom = 0;
zombieRoom = 0;
numBullets = 0;
numRooms = 0;
haveGrail = false;
}
//pre: no preconditions
//post: displays a menu which calls printMemory and instructions
bool menu(int ¤tRoom, int &zombieRoom, int &numBullets, int &numRooms, bool &haveGrail, int gameArray[],int roomArray[][7])
{
int menuSelection;
cout << " Enter, if you dare...\n";
cout << "*** THE TOMB OF THE BLIND DEAD ***\n";
cout << " Main Menu \n";
cout << "1. Instructions\n"
<< "2. Begin\n"
<< "3. Exit\n";
cout << "Enter Menu Selection: ";
cin >> menuSelection;
while (menuSelection < 1 || menuSelection > 3)
{
cout << "You MUST choose an option between 1 and 3.\n"
<< "Enter Menu Selection: ";
cin >> menuSelection;
}
switch(menuSelection)
{
case '1': printMemory(gameArray, roomArray); //usually there's an error here
break;
case '2': instructions();
break;
case '3': return 0;
break;
}
return 0;
}
//pre: no preconditions
//post: displays the instructions to the player
void instructions()
{
cout << "YOUR MISSION, SHOULD YOU CHOOSE TO ACCEPT IT, IS TO SEEK THE HOLY\n"
<< "GRAIL WITHIN THE RUINS OF AN ANCIENT CHURCH. TO SUCCEED YOU MUST\n"
<< "ENTER THE CHURCH, AVOID THE UNDEAD GUARDIANS, FIND THE GRAIL AND\n"
<< "ESCAPE. YOU HAVE SIX SILVER BULLETS TO PROTECT YOU. IF THE ZOMBIES\n"
<< "FIND YOU OR YOU RUN OUT OF BULLETS YOU WILL LOSE!\n";
}
void printMemory(int gameArray, int roomArray[]) //usually there's an error here
{
for (int index = 0; index < MAX_ROOMS; ++index)
{
std::cout << "GOOD" << std::endl;
}
}
|