Answered step by step
Verified Expert Solution
Question
1 Approved Answer
#include #include #include #include #include struct Room { enum class Name { cell, gate, armory, jailers, exit } ; enum class Direction { N ,
#include
#include
#include
#include
#include
struct Room
enum class Name cell, gate, armory, jailers, exit ;
enum class Direction N S E W none ;
std::string message; the message displayed when in the room.
std::vector doors; the directions in which there are doors.
std::vector connectedRoom; the name of the room in which the corresponding door leads.
NOTE:: these two vectors will eventually become a std::map after the STL level.
bool hasKey false ; whether or not the player has picked up the key.
;
struct Player
Room::Name currentRoom Room::Name::cell ;
int health;
bool hasKey false ;
;
GUI Functions
void clearConsole;
void pauseConsole;
void splashScreen;
void displayGameStateconst Player& player, const std::vector& map;
void displayGameDoneconst Player& player, const std::vector& map;
void displayIllegalMoveconst Player& player, Room::Direction action;
Room::Direction getAction;
Engine Functions
std::vector buildMap;
void randomizeKeystd::vector& map;
bool changeGameStateRoom::Direction action, Player& player, std::vector& map;
bool gameIsNotDoneconst Player& player;
int main
Splash Screen
clearConsole;
splashScreen;
set up game
std::vector map buildMap;
Player player;
Until Game Termination Condition
while gameIsNotDoneplayer
Display Game State
clearConsole;
displayGameStateplayer map;
Collect Player Action
Room::Direction action getAction;
Update Game State
if changeGameStateaction player, map
displayIllegalMoveplayer action;
Display Termination Game State
displayGameDoneplayer map;
return ;
std::vector buildMap
std::vector map;
map.pushback
"A small, dark prison cell with doors South and East.",
Room::Direction::S Room::Direction::E
Room::Name::armory, Room::Name::gate
false
;
map.pushback
"A large, torchlit room with doors West, South, and East.
There is daylight entering under the door to the East.",
Room::Direction::W Room::Direction::S Room::Direction::E
Room::Name::cell, Room::Name::jailers, Room::Name::exit
false
;
map.pushback
"A store room with doors North and East.",
Room::Direction::N Room::Direction::E
Room::Name::cell, Room::Name::jailers
false
;
map.pushback
"A jailer's barracks with doors West and North.",
Room::Direction::W Room::Direction::N
Room::Name::armory, Room::Name::gate
true
;
map.pushback
"YOU FOUND THE KEY AND ESCAPED!",
false
;
return map;
void clearConsole
systemcls;
void pauseConsole
systemPAUSE;
void splashScreen
std::cout "DUNGEON ADVENTURE" std::endl;
std::cout std::endl;
std::cout "Your name here std::endl;
std::cout CPSC Programming II Level Quest" std::endl;
std::cout UA Little Rock, Computer Science Dept." std::endl;
std::cout std::endl;
std::cout "INSTRUCTIONS:" std::endl;
std::cout std::endl;
std::cout "Find the key and get out of the dungeon!" std::endl;
std::cout std::endl;
std::cout North std::endl;
std::cout w std::endl;
std::cout std::endl;
std::cout West a d East std::endl;
std::cout std::endl;
std::cout s std::endl;
std::cout South std::endl;
std::cout std::endl;
pauseConsole;
Task : Change the vector of rooms to a map. moderate
This is the easiest change. Change the std::vector
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started