"Development Topic: Text Game" it sounds fancy, but it's not.
I'm kinda stuck atm, because my program doesn't do what I want it to do.
Here is what I got so far;
Code: Select all
#include <iostream>
using namespace std;
//character
string nickname;
string skills;
string ShowSkills;
string ShowItems;
string items;
int gold;
//game
string input;
string direction;
static string place_name = "Place Name"; // so it doesnt resets
string description;
string exits;
// pos
int x = 0;
int y = 0;
// static
//bool running = true;
void position();
void cityhall();
int main()
{
cout << "What's your name adventurer? ";
cin >> nickname;
system("CLS");
cout << "Welcome to the world of err... pizza....." << nickname << endl;
cout << "start your journey now, type start to continue." << endl;
cout << "\n\n" << endl; // spacer
cin >> input;
if (input == "start"){
system("CLS");
}
else
{
cout << "Error, please type start. " << endl;
system("pause");
}
while(input != "exit") {
position();
cin >> input;
if (input == "n" || input == "north"){ y += 1; }
if (input == "e" || input == "east") { x += 1; }
if (input == "s" || input == "south"){ y -= 1; }
if (input == "w" || input == "west") { x -= 1; }
if (input == "!skills") { ShowSkills; }
if (input == "!items") { ShowItems; }
}
}
void position()
{
cout << "[[" << place_name << "]] <" << x << ", " << y << ">" << endl;
cout << description << endl;
cout << "\n\n" << endl; // spacer
}
// City Hall
void cityhall()
{
x = 0;
y = 0;
exits = "n";
place_name = "City Hall";
cout << "This is the central gathering room. The room is fairly " << endl;
cout << "empty, except for a large table in center of the room." << endl;
cout << "There is an exit to the north that leads out into town." << endl;
}
// Main Street
void mainstreet()
{
x = 0;
y = 1;
exits = "w" "e";
place_name = "Main Street";
cout << "This is the main street, there is a big statue of the king " << endl;
cout << "in the middle of the street. The cobbeld pavement continues " << endl;
cout << "to the east and west. " << endl;
}
/*
// Stats and Skills
int Health = 100;
int Mana = 20;
int level = 1;
void ShowSkills()
{
cout << "You've currently got:" << endl;
cout << "You got: " << Health << " HP points." << endl;
cout << "You got: " << Mana << " MP points."<< endl;
cout << "\n\n" << endl;
cout << "You are currently level " << level << "." << endl;
}
void ShowItems()
{
cout << "You got " << gold << " gold pieces." << endl;
cout << "You are carrying:" << endl;
cout << items << endl;
}
*/
Please ignore the complete stats and skills part!
Well, I want the program to start and output
"[[City Hall]] <0, 0>"
but it outputs
"[[Place name]] <0, 0>"
when I "update" it (I press N) it does work, but not at the start!
It's hard to explain, but basically the just displays "position" while it should display "city hall" with the template of "position" (the [[name]] etc).