Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion basicGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
56 changes: 56 additions & 0 deletions location.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#include <string>
#include <iostream>
#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;
}
20 changes: 20 additions & 0 deletions location.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef Location_H
#define Location_H
#include <string>

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
16 changes: 7 additions & 9 deletions printer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

}
Expand Down