Best writers. Best papers. Let professionals take care of your academic papers

Order a similar paper and get 15% discount on your first order with us
Use the following coupon "FIRST15"
ORDER NOW

In my homework we have to take an existing code

In my homework we have to take an existing code and implement functions in it to make it more readable and

condense it.

 ATTACHMENT PREVIEW Download attachment// GSP115 TREASURE CAVE// Week 4#pragma once#include “GSP115_Course_Project.h”// Global Constantsconst 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 Constantsconst char ULC = 201;//Upper left cornerconst char HB = 205;//Horizontal borderconst char URC = 187;//Upper right cornerconst char VB = 186;//Vertical borderconst char LRC = 188;//Lower right cornerconst char LLC = 200;//Lower left cornerconst char MT = ‘ ‘;//Empty locationconst char PSymbol = ‘P’;//Player symbolconst char TOSymbol = ‘T’;//Torch symbolconst char WSymbol = ‘W’;//Weapon symbolconst char TRSymbol = ‘$’;//Treasure symbolconst char MSymbol = ‘M’;//Monster symbolconst char NSymbol = ‘N’;//Noisemaker symbolconst char XSymbol = ‘X’;//Cave exit symbolusing namespace std;// function prototypesgameObject placeInCave( gameObjectType array[TOTAL_ROWS][TOTAL_COLS]);// <WK4 status=permanent>bool checkVisible(gameObject x, gameObject y, int dist );// </WK4>bool showOnBoard(gameObject x);int main(){//**Initialize Variables**srand(time(NULL));// Seed the random number functiongameObjectType cave[TOTAL_ROWS][TOTAL_COLS];// the cave–a twodimensional arraychar board[TOTAL_ROWS+3][TOTAL_COLS+3]=// the game board–a twodimensional 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

Background image of page 1

View the AnswergameObject treasure = {-1, -1, false, true};// the treasuregameObject monster = {-1, -1, false, true};// the monstergameObject weapon = {-1, -1, false, true};// the weapon// <WK4 status=permanent>gameObject torch = {-1, -1, false, true};// the torchgameObject noisemaker = {-1, -1, false, true}; // the noisemaker// </WK4>int row, column;// temporarily hold the new playerpositionint MonsterMoveCounter = 6;// track and control monster movementaround treasurestring msg;// status message variablechar command;// player input// <WK4 status=permanent>bool monsterPause = false;// flag to indicate the monster hasstopped moving// </WK4>bool movePlayer = true;// flag to indicate the player position canbe updatedbool gameOver = false;// status flag//**Prepare Cave***********//…Initialize an empty cavefor (gameObjectType (&R)[TOTAL_COLS] : cave){for (auto &C : R) C = EMPTY;}//…Add player in rows 0-2, columns 0-2player.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-6treasure.row = rand()%3 + 4;treasure.column = rand()%6 +1;cave[treasure.row][treasure.column] = TREASURE;//…Add Monster at treasure row +1 , column -1monster.row = treasure.row + 1;monster.column = treasure.column -1;cave[monster.row][monster.column] = MONSTER;//…Add Weapon in any empty locationweapon = placeInCave(cave);cave[weapon.row][weapon.column] = WEAPON;// <WK4 status=permanent>//…Add Noisemaker in any empty locationnoisemaker = placeInCave(cave);cave[noisemaker.row][noisemaker.column] = NOISEMAKER;//…Add Torch in any empty locationtorch = placeInCave(cave);cave[torch.row][torch.column] = TORCH;// </WK4>//**Play Game*************//…Begin Game Loopwhile (!gameOver){//….Display Board// <WK4 status=permanent>//…..Check visibilityif (!player.hasTorch){torch.isVisible = checkVisible(player.position, torch, 2);weapon.isVisible = checkVisible(player.position, weapon, 2);treasure.isVisible = checkVisible(player.position, treasure,2);

Background image of page 2

Show

 
Looking for a Similar Assignment? Order now and Get 10% Discount! Use Coupon Code "Newclient"