(Solved Homework): Review the code and determine where functions could be used in place of existing code in main to make the code

Review the code and determine where functions could be used in place of existing code in main to make the code easier to read and maintain. Also, before making changes, note all the code behaviors you think need improving.

.cpp file

// GSP115 TREASURE CAVE
// Week 4
#pragma once
#include “GSP115_Course_Project.h”

// Global Constants
const int MAX_ROWS = 7;
const int MIN_ROWS = 0;
const int MAX_COLS = 7;
const int MIN_COLS = 0;
const int TOTAL_ROWS = MAX_ROWS + 1;
const int TOTAL_COLS = MAX_COLS + 1;

//Display Constants
const char ULC = 201;       //Upper left corner
const char HB = 205;       //Horizontal border
const char URC = 187;       //Upper right corner
const char VB = 186;       //Vertical border
const char LRC = 188;       //Lower right corner
const char LLC = 200;       //Lower left corner
const char MT = ‘ ‘;       //Empty location
const char PSymbol = ‘P’;   //Player symbol
const char TOSymbol = ‘T’;   //Torch symbol
const char WSymbol = ‘W’;   //Weapon symbol
const char TRSymbol = ‘$’;   //Treasure symbol
const char MSymbol = ‘M’;   //Monster symbol
const char NSymbol = ‘N’;   //Noisemaker symbol
const char XSymbol = ‘X’;   //Cave exit symbol

using namespace std;

// function prototypes
gameObject placeInCave(gameObjectType array[TOTAL_ROWS][TOTAL_COLS]);
bool checkVisible(gameObject x, gameObject y, int dist);
bool showOnBoard(gameObject x);

int main()
{
//**Initialize Variable**
srand(time(NULL));       // Seed the random number function

gameObjectType cave[TOTAL_ROWS][TOTAL_COLS];   // the cave–a two dimensional array
char board[TOTAL_ROWS + 3][TOTAL_COLS + 3] =       // the game board–a two dimensional array
{
{ MT,MT,’0′,’1′,’2′,’3′,’4′,’5′,’6′,’7′,MT },
{ MT,ULC,HB,HB,HB,HB,HB,HB,HB,HB,URC },
{ ‘A’,VB,MT,MT,MT,MT,MT,MT,MT,MT,VB },
{ ‘B’,VB,MT,MT,MT,MT,MT,MT,MT,MT,VB },
{ ‘C’,VB,MT,MT,MT,MT,MT,MT,MT,MT,VB },
{ ‘D’,VB,MT,MT,MT,MT,MT,MT,MT,MT,VB },
{ ‘E’,VB,MT,MT,MT,MT,MT,MT,MT,MT,VB },
{ ‘F’,VB,MT,MT,MT,MT,MT,MT,MT,MT,VB },
{ ‘G’,VB,MT,MT,MT,MT,MT,MT,MT,MT,VB },
{ ‘H’,VB,MT,MT,MT,MT,MT,MT,MT,MT,VB },
{ MT,LLC,HB,HB,HB,HB,HB,HB,HB,HB,LRC }
};

playerObject player = { true, false, false, false, false,{ -1, -1, false, true } };   // the player
gameObject treasure = { -1, -1, false, true };       // the treasure
gameObject monster = { -1, -1, false, true };       // the monster
gameObject weapon = { -1, -1, false, true };       // the weapon
gameObject torch = { -1, -1, false, true };       // the torch
gameObject noisemaker = { -1, -1, false, true };   // the noisemaker
int row, column;               // temporarily hold the new player position
int MonsterMoveCounter = 6;       // track and control monster movement around treasure
string msg;               // status message variable
char command;               // player input
bool monsterPause = false;   // flag to indicate the monster has stopped moving
bool movePlayer = true;       // flag to indicate the player position can be updated
bool gameOver = false;       // status flag

//**Prepare Cave***********
//…Initialize an empty cave
for (gameObjectType(&R)[TOTAL_COLS] : cave)
{
for (auto &C : R) C = EMPTY;
}

//…Add player in rows 0-2, columns 0-2
player.position.row = rand() % 3;
player.position.column = rand() % 3;
cave[player.position.row][player.position.column] = PLAYER;
//…Add Treasure in rows 4-6, column 1-6
treasure.row = rand() % 3 + 4;
treasure.column = rand() % 6 + 1;
cave[treasure.row][treasure.column] = TREASURE;
//…Add Monster at treasure row +1 , column -1
monster.row = treasure.row + 1;
monster.column = treasure.column – 1;
cave[monster.row][monster.column] = MONSTER;
//…Add Weapon in any empty location
weapon = placeInCave(cave);
cave[weapon.row][weapon.column] = WEAPON;
//…Add Noisemaker in any empty location
noisemaker = placeInCave(cave);
cave[noisemaker.row][noisemaker.column] = NOISEMAKER;
//…Add Torch in any empty location
torch = placeInCave(cave);
cave[torch.row][torch.column] = TORCH;
//**Play Game*************
//…Begin Game Loop
while (!gameOver)
{
//….Display Board
//…..Check visibility
if (!player.hasTorch)
{
torch.isVisible = checkVisible(player.position, torch, 2);
weapon.isVisible = checkVisible(player.position, weapon, 2);
treasure.isVisible = checkVisible(player.position, treasure, 2);
monster.isVisible = checkVisible(player.position, monster, 2);
noisemaker.isVisible = checkVisible(player.position, noisemaker, 2);
}
//…..Place visible objects on board–note: changing the order below will create a visual bug.
board[weapon.row + 2][weapon.column + 2] = showOnBoard(weapon) ? WSymbol : MT;
board[torch.row + 2][torch.column + 2] = showOnBoard(torch) ? TOSymbol : MT;
board[treasure.row + 2][treasure.column + 2] = showOnBoard(treasure) ? TRSymbol : MT;
board[noisemaker.row + 2][noisemaker.column + 2] = showOnBoard(noisemaker) ? NSymbol : MT;
board[monster.row + 2][monster.column + 2] = showOnBoard(monster) ? MSymbol : MT;
board[player.position.row + 2][player.position.column + 2] = player.alive ? PSymbol : MT;

// Put the board on the screen
for (char(&R)[TOTAL_COLS + 3] : board)
{
for (char &C : R)
{
cout << C;
}
cout << endl;
}

cout << msg.c_str() << endl;
//….Get command
cout << “What is your command? “;
cin >> command;
//….Clear display and message
msg.clear();
system(“cls”);
//….Process player command
row = player.position.row;
column = player.position.column;
switch (command)
{
case ‘a’:
column = player.position.column – 1;
if (column < MIN_COLS)
{
column = player.position.column;
msg = “You have hit the west wall!”;
}
break;
case ‘s’:
row = player.position.row + 1;
if (row > MAX_ROWS)
{
row = player.position.row;
msg = “You have hit the south wall!”;
}
break;
case ‘w’:
column = player.position.column;//Is this really needed?
row = player.position.row – 1;
if (row < MIN_ROWS)
{
row = player.position.row;
msg = “You have hit the north wall!”;
}
break;
case ‘d’:
row = player.position.row;//Is this really needed?
column = player.position.column + 1;
if (column > MAX_COLS)
{
column = player.position.column;
msg = “You have hit the east wall!”;
}
break;
case ‘n’:
if (player.hasNoisemaker)
{
msg = “You make an irritating noise!”;
monsterPause = true;
}
else
{
msg = “You make a feeble whimper.”;
}
break;
case ‘q’:
gameOver = true;
msg = “Quitting?n”;
break;
default:
movePlayer = false;
break;
}
//….Check if the game is over
if (!gameOver)
{

//….. Check for events
switch (cave[row][column])
{
//……If treasure found, set flag to show player has treasure
case TREASURE:
player.hasTreasure = true;
treasure.isFound = true;
msg = “You found the treasure!”;
gameOver = true;
break;
//……If weapon found, set flag to show player has weapon
case WEAPON:
player.hasWeapon = true;
weapon.isFound = true;
msg = “You have a weapon.”;
break;
//……If noise-maker found, set flag to show player has noise-maker
case NOISEMAKER:
player.hasNoisemaker = true;
noisemaker.isFound = true;
msg = “You found a noisemaker.”;
break;
//……If torch found, set flag to show player has torch
case TORCH:
player.hasTorch = true;
torch.isFound = true;
msg = “Let there be light! You found a torch.”;
weapon.isVisible = true;
treasure.isVisible = true;
noisemaker.isVisible = true;
monster.isVisible = true;
break;
//……If monster found
case MONSTER:
if (!monster.isFound)
{
msg = “You have found the monster”;
//…….Resolve combat
if (player.hasWeapon)
{
msg = “You have slain the monster”;
monster.isFound = true;
}
else
{
gameOver = true;
player.alive = false;
msg = “The monster has killed you”;
}
}
break;
}
//…..Move Player
if (movePlayer)
{
cave[player.position.row][player.position.column] = EMPTY;       //updates position information
cave[row][column] = PLAYER;
board[player.position.row + 2][player.position.column + 2] = MT;   //clear the screen where player was
player.position.row = row;
player.position.column = column;
}
movePlayer = true;
//…..Process Monster
if (!monster.isFound)
{
if (monsterPause)
{
// Monster paused. Check if Monster starts moving again
if (rand() % 3 == 1)
{
monsterPause = false;
}
}
else
{
//……Move Monster
MonsterMoveCounter = (++MonsterMoveCounter) % 8;
row = monster.row;
column = monster.column;
switch (MonsterMoveCounter)
{
case 0:
column++;
break;
case 1:
row–;
break;
case 2:
row–;
break;
case 3:
column–;
break;
case 4:
column–;
break;
case 5:
row++;
break;
case 6:
row++;
break;
case 7:
column++;
break;
default:
break;
}
//……Check for events
//…….If player found
if (cave[row][column] == PLAYER)
{
msg = “The monster has found you”;
//……..Resolve combat
if (player.hasWeapon)
{
msg = “The monster found you but was slain”;
monster.isFound = true;
}
else
{
gameOver = true;
player.alive = false;
msg = “The monster found you and you have died”;
}
}
else
{
//……..Move Monster
//cave[monster.row][monster.column] = hold;       // reveal what is under the monster
cave[monster.row][monster.column] = EMPTY;   // clear the cave location
board[monster.row + 2][monster.column + 2] = MT;   // clear the screen behind monster
//hold = cave[row][column];                       // save what the monster is about to move over
monster.row = row;                               // update monster’s row
monster.column = column;                       // update monster’s column
cave[row][column] = MONSTER;                   // change monster’s location in the cave
}
}

}
}
}
//…End Game Loop
//**End Game**************
//…Provide end win/loss message
cout << msg.c_str() << endl;
if (player.alive)
{
if (player.hasTreasure) msg = “You are alive and rich!”;
else msg = “You didn’t get the treasure, but you live to seek adventure another day.”;
}
else
{
msg = “RIP Adventurer”;
}
cout << msg.c_str() << endl;
//…Do clean-up
//…Quit
return 0;
}

//——————————————————————————–
//================================================================================

gameObject placeInCave(gameObjectType array[TOTAL_ROWS][TOTAL_COLS])
{
int r, c;
gameObject obj;
do
{
r = rand() % 8;
c = rand() % 8;
} while (array[r][c] != EMPTY);
obj.row = r;
obj.column = c;
obj.isFound = false;
return obj;
}

bool checkVisible(gameObject x, gameObject y, int dist)
{
if ((abs(x.row – y.row) < dist && (abs(x.column – y.column) < dist))) return true;
return false;
}

bool showOnBoard(gameObject x)
{
return ((x.isVisible) && (!x.isFound));
}

.h file

#pragma once
#include
#include
#include
#include
#include
#include

enum gameObjectType
{
EMPTY, PLAYER, TREASURE, MONSTER, WEAPON, TORCH, NOISEMAKER//, CAVE_EXIT -add in week 6
};

struct gameObject
{
int row;                       // row position of the object
int column;                    // column position of the object
bool isFound;          // flag to indicate if the object has been found (or is dead, in the case of the monster)
bool isVisible;        // flag to indicate if the object can be seen on the board
};

struct playerObject
{
bool alive;            // flag to indicate if the player is alive or dead
bool hasWeapon;        // flag to indicate if the player has the weapon
bool hasTreasure;     // flag to indicate if the player has the treasure
bool hasTorch;         // flag to indicate if the player has the torch
bool hasNoisemaker;    // flag to indicate if the player has the noisemaker
gameObject position;   // variables for row, column and visibility
};

This is the output:

***Picture wont attach*** Its a game board with the letter ‘P’ for player and below the board says, “What is your command?”

It is a game where you use wasd for movement and you are trying to find the treasure before the monster gets you.

I am to add in functions to clear up the code while notating what is being done to the code. I find that the code just shuts down when finding the treasure. I have played around with the functions but cannot get the program to run properly.

Expert Answer

 

Copyable code:

File Name: main.cpp

#include “GSP115_Course_Project.h”

#include <iostream>

#include <string>

#include <ctime>

// Global Constants

const int MAX_ROWS = 7;

const int MIN_ROWS = 0;

const int MAX_COLS = 7;

const int MIN_COLS = 0;

const int TOTAL_ROWS = MAX_ROWS + 1;

const int TOTAL_COLS = MAX_COLS + 1;

//Display Constants

const char ULC = 201;       //Upper left corner

const char HB = 205;       //Horizontal border

const char URC = 187;       //Upper right corner

const char VB = 186;       //Vertical border

const char LRC = 188;       //Lower right corner

const char LLC = 200;       //Lower left corner

const char MT = ‘ ‘;       //Empty location

const char PSymbol = ‘P’;   //Player symbol

const char TOSymbol = ‘T’;   //Torch symbol

const char WSymbol = ‘W’;   //Weapon symbol

const char TRSymbol = ‘$’;   //Treasure symbol

const char MSymbol = ‘M’;   //Monster symbol

const char NSymbol = ‘N’;   //Noisemaker symbol

const char XSymbol = ‘X’;   //Cave exit symbol

using namespace std;

// function prototypes

void initializeGameObject(gameObjectType array[TOTAL_ROWS][TOTAL_COLS]);

void displayGameBoard(char array[TOTAL_ROWS+3][TOTAL_COLS+3]);

gameObject placeInCave(gameObjectType array[TOTAL_ROWS][TOTAL_COLS]);

bool checkVisible(gameObject x, gameObject y, int dist);

bool showOnBoard(gameObject x);

int main()

{

//**Initialize Variable**

srand(time(NULL));       // Seed the random number function

gameObjectType cave[TOTAL_ROWS][TOTAL_COLS];   // the cave–a two dimensional array

char board[TOTAL_ROWS + 3][TOTAL_COLS + 3] =       // the game board–a two dimensional array

{

{ MT,MT,’0′,’1′,’2′,’3′,’4′,’5′,’6′,’7′,MT },

{ MT,ULC,HB,HB,HB,HB,HB,HB,HB,HB,URC },

{ ‘A’,VB,MT,MT,MT,MT,MT,MT,MT,MT,VB },

{ ‘B’,VB,MT,MT,MT,MT,MT,MT,MT,MT,VB },

{ ‘C’,VB,MT,MT,MT,MT,MT,MT,MT,MT,VB },

{ ‘D’,VB,MT,MT,MT,MT,MT,MT,MT,MT,VB },

{ ‘E’,VB,MT,MT,MT,MT,MT,MT,MT,MT,VB },

{ ‘F’,VB,MT,MT,MT,MT,MT,MT,MT,MT,VB },

{ ‘G’,VB,MT,MT,MT,MT,MT,MT,MT,MT,VB },

{ ‘H’,VB,MT,MT,MT,MT,MT,MT,MT,MT,VB },

{ MT,LLC,HB,HB,HB,HB,HB,HB,HB,HB,LRC }

};

playerObject player = { true, false, false, false, false,{ -1, -1, false, true } };   // the player

gameObject treasure = { -1, -1, false, true };       // the treasure

gameObject monster = { -1, -1, false, true };       // the monster

gameObject weapon = { -1, -1, false, true };       // the weapon

gameObject torch = { -1, -1, false, true };       // the torch

gameObject noisemaker = { -1, -1, false, true };   // the noisemaker

int row, column;               // temporarily hold the new player position

int MonsterMoveCounter = 6;       // track and control monster movement around treasure

string msg;               // status message variable

char command;               // player input

bool monsterPause = false;   // flag to indicate the monster has stopped moving

bool movePlayer = true;       // flag to indicate the player position can be updated

bool gameOver = false;       // status flag

//**Prepare Cave***********

//…Initialize an empty cave

//Call Function.

initializeGameObject(cave);

 

//…Add player in rows 0-2, columns 0-2

player.position.row = rand() % 3;

player.position.column = rand() % 3;

cave[player.position.row][player.position.column] = PLAYER;

//…Add Treasure in rows 4-6, column 1-6

treasure.row = rand() % 3 + 4;

treasure.column = rand() % 6 + 1;

cave[treasure.row][treasure.column] = TREASURE;

//…Add Monster at treasure row +1 , column -1

monster.row = treasure.row + 1;

monster.column = treasure.column – 1;

cave[monster.row][monster.column] = MONSTER;

//…Add Weapon in any empty location

weapon = placeInCave(cave);

cave[weapon.row][weapon.column] = WEAPON;

//…Add Noisemaker in any empty location

noisemaker = placeInCave(cave);

cave[noisemaker.row][noisemaker.column] = NOISEMAKER;

//…Add Torch in any empty location

torch = placeInCave(cave);

cave[torch.row][torch.column] = TORCH;

//**Play Game*************

//…Begin Game Loop

while (!gameOver)

{

//….Display Board

//…..Check visibility

if (!player.hasTorch)

{

torch.isVisible = checkVisible(player.position, torch, 2);

weapon.isVisible = checkVisible(player.position, weapon, 2);

treasure.isVisible = checkVisible(player.position, treasure, 2);

monster.isVisible = checkVisible(player.position, monster, 2);

noisemaker.isVisible = checkVisible(player.position, noisemaker, 2);

}

//…..Place visible objects on board–note: changing the order below will create a visual bug.

board[weapon.row + 2][weapon.column + 2] = showOnBoard(weapon) ? WSymbol : MT;

board[torch.row + 2][torch.column + 2] = showOnBoard(torch) ? TOSymbol : MT;

board[treasure.row + 2][treasure.column + 2] = showOnBoard(treasure) ? TRSymbol : MT;

board[noisemaker.row + 2][noisemaker.column + 2] = showOnBoard(noisemaker) ? NSymbol : MT;

board[monster.row + 2][monster.column + 2] = showOnBoard(monster) ? MSymbol : MT;

board[player.position.row + 2][player.position.column + 2] = player.alive ? PSymbol : MT;

//Call Function.

displayGameBoard(board);

cout << msg.c_str() << endl;

//….Get command

cout << “What is your command? “;

cin >> command;

//….Clear display and message

msg.clear();

system(“cls”);

//….Process player command

row = player.position.row;

column = player.position.column;

switch (command)

{

case ‘a’:

column = player.position.column – 1;

if (column < MIN_COLS)

{

column = player.position.column;

msg = “You have hit the west wall!”;

}

break;

case ‘s’:

row = player.position.row + 1;

if (row > MAX_ROWS)

{

row = player.position.row;

msg = “You have hit the south wall!”;

}

break;

case ‘w’:

column = player.position.column;//Is this really needed?

row = player.position.row – 1;

if (row < MIN_ROWS)

{

row = player.position.row;

msg = “You have hit the north wall!”;

}

break;

case ‘d’:

row = player.position.row;//Is this really needed?

column = player.position.column + 1;

if (column > MAX_COLS)

{

column = player.position.column;

msg = “You have hit the east wall!”;

}

break;

case ‘n’:

if (player.hasNoisemaker)

{

msg = “You make an irritating noise!”;

monsterPause = true;

}

else

{

msg = “You make a feeble whimper.”;

}

break;

case ‘q’:

gameOver = true;

msg = “Quitting?n”;

break;

default:

movePlayer = false;

break;

}

//….Check if the game is over

if (!gameOver)

{

//….. Check for events

switch (cave[row][column])

{

//……If treasure found, set flag to show player has treasure

case TREASURE:

player.hasTreasure = true;

treasure.isFound = true;

msg = “You found the treasure!”;

gameOver = true;

break;

//……If weapon found, set flag to show player has weapon

case WEAPON:

player.hasWeapon = true;

weapon.isFound = true;

msg = “You have a weapon.”;

break;

//……If noise-maker found, set flag to show player has noise-maker

case NOISEMAKER:

player.hasNoisemaker = true;

noisemaker.isFound = true;

msg = “You found a noisemaker.”;

break;

//……If torch found, set flag to show player has torch

case TORCH:

player.hasTorch = true;

torch.isFound = true;

msg = “Let there be light! You found a torch.”;

weapon.isVisible = true;

treasure.isVisible = true;

noisemaker.isVisible = true;

monster.isVisible = true;

break;

//……If monster found

case MONSTER:

if (!monster.isFound)

{

msg = “You have found the monster”;

//…….Resolve combat

if (player.hasWeapon)

{

msg = “You have slain the monster”;

monster.isFound = true;

}

else

{

gameOver = true;

player.alive = false;

msg = “The monster has killed you”;

}

}

break;

}

//…..Move Player

if (movePlayer)

{

cave[player.position.row][player.position.column] = EMPTY;       //updates position information

cave[row][column] = PLAYER;

board[player.position.row + 2][player.position.column + 2] = MT;   //clear the screen where player was

player.position.row = row;

player.position.column = column;

}

movePlayer = true;

//…..Process Monster

if (!monster.isFound)

{

if (monsterPause)

{

// Monster paused. Check if Monster starts moving again

if (rand() % 3 == 1)

{

monsterPause = false;

}

}

else

{

//……Move Monster

MonsterMoveCounter = (++MonsterMoveCounter) % 8;

row = monster.row;

column = monster.column;

switch (MonsterMoveCounter)

{

case 0:

column++;

break;

case 1:

row–;

break;

case 2:

row–;

break;

case 3:

column–;

break;

case 4:

column–;

break;

case 5:

row++;

break;

case 6:

row++;

break;

case 7:

column++;

break;

default:

break;

}

//……Check for events

//…….If player found

if (cave[row][column] == PLAYER)

{

msg = “The monster has found you”;

//……..Resolve combat

if (player.hasWeapon)

{

msg = “The monster found you but was slain”;

monster.isFound = true;

}

else

{

gameOver = true;

player.alive = false;

msg = “The monster found you and you have died”;

}

}

else

{

//……..Move Monster

//cave[monster.row][monster.column] = hold;       // reveal what is under the monster

cave[monster.row][monster.column] = EMPTY;   // clear the cave location

board[monster.row + 2][monster.column + 2] = MT;   // clear the screen behind monster

//hold = cave[row][column];                       // save what the monster is about to move over

monster.row = row;                               // update monster’s row

monster.column = column;                       // update monster’s column

cave[row][column] = MONSTER;                   // change monster’s location in the cave

}

}

}

}

}

//…End Game Loop

//**End Game**************

//…Provide end win/loss message

cout << msg.c_str() << endl;

if (player.alive)

{

if (player.hasTreasure) msg = “You are alive and rich!”;

else msg = “You didn’t get the treasure, but you live to seek adventure another day.”;

}

else

{

msg = “RIP Adventurer”;

}

cout << msg.c_str() << endl;

//…Do clean-up

//…Quit

system(“pause”);

return 0;

}

//——————————————————————————–

//================================================================================

//Method intializes the cave array

void initializeGameObject(gameObjectType array[TOTAL_ROWS][TOTAL_COLS])

{

//Declare Loop variables.

int kk,aa;

//Outer For Loop.

for(kk=0;kk<TOTAL_ROWS;kk++)

{

//Inner For Loop.

for(aa=0;aa<TOTAL_COLS;aa++)

{

//Set Value.

array[kk][aa]=EMPTY;

}

}

}

//Define method to display the game board.

void displayGameBoard(char array[TOTAL_ROWS+3][TOTAL_COLS+3])

{

//Declare Loop Variables.

int kk,aa;

//Outer For Loop

for(kk=0;kk<TOTAL_ROWS+3;kk++)

{

//Inner For Loop

for(aa=0;aa<TOTAL_COLS+3;aa++)

{

//Display.

cout << array[kk][aa];

}

//New line

cout << endl;

}

}

gameObject placeInCave(gameObjectType array[TOTAL_ROWS][TOTAL_COLS])

{

int r, c;

gameObject obj;

do

{

r = rand() % 8;

c = rand() % 8;

} while (array[r][c] != EMPTY);

obj.row = r;

obj.column = c;

obj.isFound = false;

return obj;

}

bool checkVisible(gameObject x, gameObject y, int dist)

{

if ((abs(x.row – y.row) < dist && (abs(x.column – y.column) < dist)))

return true;

return false;

}

bool showOnBoard(gameObject x)

{

return ((x.isVisible) && (!x.isFound));

}

File Name: GSP115_Course_Project.h

#pragma once

#include <iostream>

#include <string>

#include <ctime>

using namespace std;

enum gameObjectType

{

EMPTY, PLAYER, TREASURE, MONSTER, WEAPON, TORCH, NOISEMAKER//, CAVE_EXIT -add in week 6

};

struct gameObject

{

int row;                       // row position of the object

int column;                    // column position of the object

bool isFound;          // flag to indicate if the object has been found (or is dead, in the case of the monster)

bool isVisible;        // flag to indicate if the object can be seen on the board

};

struct playerObject

{

bool alive;            // flag to indicate if the player is alive or dead

bool hasWeapon;        // flag to indicate if the player has the weapon

bool hasTreasure;     // flag to indicate if the player has the treasure

bool hasTorch;         // flag to indicate if the player has the torch

bool hasNoisemaker;    // flag to indicate if the player has the noisemaker

gameObject position;   // variables for row, column and visibility

};

iWriteHomework
Order NOW for a 10% Discount
Pages (550 words)
Approximate price: -

Why Us?

Top Quality and Well-Researched Papers

All ourbpapers are written from scratch. In fact, Clients who ask for paraphrasing services are highly discouraged. We have writers ready to craft any paper from scratch and deliver quality ahead of time.

Professional and Experienced Academic Writers

Our writers keeps you posted on your papers progress - providing you with paper outline/draft. You are also at liberty to communicate directly with your writer.

Free Unlimited Revisions

If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.

Prompt Delivery and 100% Money-Back-Guarantee

All papers are always delivered on time, in many cases quite ahead of time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.

Original & Confidential

We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.

24/7 Customer Support

Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.

Try it now!

Calculate the price of your order

Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

Our Services

No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.

Essays

Essay Writing Service

No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.

Admissions

Admission Essays & Business Writing Help

An admission essay is an essay or other written statement by a candidate, often a potential student enrolling in a college, university, or graduate school. You can be rest assurred that through our service we will write the best admission essay for you.

Reviews

Editing Support

Our academic writers and editors make the necessary changes to your paper so that it is polished. We also format your document by correctly quoting the sources and creating reference lists in the formats APA, Harvard, MLA, Chicago / Turabian.

Reviews

Revision Support

If you think your paper could be improved, you can request a review. In this case, your paper will be checked by the writer or assigned to an editor. You can use this option as many times as you see fit. This is free because we want you to be completely satisfied with the service offered.

× Contact Live Agents