diff --git a/basicGame.cpp b/basicGame.cpp index faca4ca..f39a428 100644 --- a/basicGame.cpp +++ b/basicGame.cpp @@ -9,7 +9,7 @@ std::string getInput(){ } std::string getHelp() { - std::string helper = "type in 'exit' to exit at any time. type in 'help' for help. type in 'look around' to get a description of where you are."; + std::string helper = "\033[1;36;44m type in 'exit' to exit at any time. type in 'help' for help. type in 'look around' to get a description of where you are.\033[0m\n"; return helper; } diff --git a/location.cpp b/location.cpp new file mode 100644 index 0000000..59d46c8 --- /dev/null +++ b/location.cpp @@ -0,0 +1,56 @@ +#include +#include +#include "location.hpp" + +Location::Location(std::string description) +{ + m_description = description; +} + +Location::Location(std::string description){ + m_description = description; +} + +void Location::lookInDirection(std::string direction){ + Location* givenDirection; + if (direction == "north"){ + givenDirection = m_north; + } else if (direction == "south"){ + givenDirection = m_south; + } else if (direction == "east"){ + givenDirection = m_east; + } else if (direction == "west"){ + givenDirection = m_west; + } + + if (givenDirection == NULL ){ + std::cout << "There's nothing in that direction." << std::endl; + } else { + givenDirection.describe(); + } +} + +void Location::setDirection(std::string direction, Location* loc){ + if (direction == "north"){ + m_north = loc; + } else if (direction == "south"){ + m_south = loc; + } else if (direction == "west"){ + m_west = loc; + } else if (direction == "east") { + m_east = loc; + } else { + std::cout << "That is not a valid direction. Please try again." << std::endl; + } +} + +void Location::setDirections(Location* north, Location* east, Location* south, Location* west){ + m_north = north; + m_east = east; + m_south = south; + m_west = west; +} + +void Location::describe(){ + std::cout << m_description << std::endl; +} diff --git a/location.hpp b/location.hpp new file mode 100644 index 0000000..7ec641c --- /dev/null +++ b/location.hpp @@ -0,0 +1,20 @@ +#ifndef Location_H +#define Location_H +#include + +class Location +{ + Location *m_north; + Location *m_east; + Location *m_south; + Location *m_west; + std::string m_description; + + public: + Location(std::string description); + void lookInDirection(std:: string direction); + void setDirection(std::string direction, Location* loc); + void setDirections(Location* north, Location* east, Location* south, Location* west); + void describe(); +}; +#endif diff --git a/printer.cpp b/printer.cpp index 024fecf..8810a81 100644 --- a/printer.cpp +++ b/printer.cpp @@ -3,19 +3,17 @@ #include "printer.hpp" void printDotLine(){ - std::cout << ". . . . . . . . . . . . . . . . . . . . . . . . . . . ." << std::endl; + std::cout << ". . . . . . . . . . . . . . . . . . . . . . . . . . . . ." << std::endl; } void printTitle(){ - std::string firstLine = R"(. ____ _____ ___ _______ __ ___ __ ___ ___ .)"; - std::string secondLine = R"(. (( \| |// \\||\\//|||| \\ || // \\||\ |||| \\ .)"; - std::string thirdLine = R"(. \\\\ /\ //|=|||| \/ ||||_// || ||=||||\\|||| )).)"; - std::string fourthLine = R"(. \_))\V/\V/|| |||| |||| ||__||| |||| \||||_// .)"; + std::string firstLine = R"(. ____ _____ ___ _______ __ ___ __ ___ ___ .)"; + std::string secondLine = R"(. (( \| |// \\||\\//|||| \\ || // \\||\ |||| \\ .)"; + std::string thirdLine = R"(. \\\\ /\ //|=|||| \/ ||||_// || ||=||||\\|||| )) .)"; + std::string fourthLine = R"(. \_))\V/\V/|| |||| |||| ||__||| |||| \||||_// .)"; + std::string wholeString = "\033[1;31m" += firstLine += "\n" += secondLine += "\n" += thirdLine += "\n" += fourthLine += "\033[0m" += "\n"; printDotLine(); - std::cout << firstLine << std::endl; - std::cout << secondLine << std::endl; - std::cout << thirdLine << std::endl; - std::cout << fourthLine << std::endl; + std::cout << wholeString; printDotLine(); }