# Text-based adventure survival horror game

This is the first couple lines of my new (will be) 8-bit co-op horror game. This is just the code for the first player text-based adventure storyline for the console game. Please critique.

//Andrew Tew
/*
First EVER Co-Op Horror Game!
*/

#include <iostream>
#include <string>
using namespace std;

int main()
{
//Declared Variables

//Title Screen and Custom Letter Output
system ("title Until Death We Part");
system ("color 0f");
system ("mode 1000");
cout << "\t\t\t\t\t\t'------------------------------'\n";
cout << "\t\t\t\t\t\t|------------------------------|\n";
cout << "\t\t\t\t\t\t|--------The first ever--------|\n";
cout << "\t\t\t\t\t\t|----8-bit Horror Game Co-Op---|\n";
cout << "\t\t\t\t\t\t|--------Survival Game---------|\n";
cout << "\t\t\t\t\t\t|--------By: Andrew Tew--------|\n";
cout << "\t\t\t\t\t\t|------------------------------|\n";
cout << "\t\t\t\t\t\t'------------------------------'\n";
cout << "\n\n\t\t\t\tPlay in Full Screen Mode/Maximized Mode for the Best Experience!\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";

/*End Start Screen

Begin Help Screen (Refrain from using Gotos)*/

system ("pause");
system ("cls");

cout << "\tHELP SCREEN:\n";
cout << "\t-----------\n\n\n";
cout << "\tyes (ALWAYS LOWERCASE)\n";
cout << "\tno (ALWAYS LOWERCASE)\n\n";
cout << "\tWHO ARE YOU:\n";
cout << "\tPOSSIBLE ETHNICITIES(ALWAYS LOWERCASE):\n";
cout << "\twhite\n";
cout << "\tblack\n";
cout << "\tasian\n";
cout << "\tlatino\n\n";
cout << "\tPOSSIBLE HAIR COLORS(ALWAYS LOWERCASE):\n";
cout << "\tblond (male)\n";
cout << "\tblonde (female)\n";
cout << "\tbrown\n";
cout << "\tblack\n";
cout << "\twhite\n";
cout << "\tgray\n\n\n\n\n\n";
cout << "Cont. Next Page\n";

system ("pause");//Next Page Help Screen
system ("cls");

cout << "\n\n\tPOSSIBLE GENDERS(ALWAYS LOWERCASE):\n";
cout << "\tmale\n";
cout << "\tfemale\n";
cout << "\tit\n\n";
cout << "\tPOSSIBLE EYE COLORS(ALWAYS LOWERCASE):\n";
cout << "\tblue\n";
cout << "\tbrown\n";
cout << "\tgreen\n";
cout << "\tgray\n\n";
cout << "\tNAME LIMITS AND MINIMUMS:\n";
cout << "\tNames must contain at LEAST 3 letters.\n";
cout << "\tNames must contain at MOST 10 letters.\n";
cout << "\tNames must NOT contain spaces.\n\n\n\n\n\n";

system ("pause");
system ("cls");

cout << "\t\t\t\t\t\tTinyBit Games Presents to you:\n";
cout << "\n\t\t\t\t\t\t           Torn\n";
/*
In the future code a "Load" Option and a "New Game" Option
Also code a "Save" option that can be done at any time
Remember this is a TEXT ADVENTURE not any other game
*/

system ("pause");//Game Begins Here Still Refrain from goto statements
system ("cls");

One:
cout << "As you begin to get up from where you are you realize that you are bound by strong\n";
cout << "rope.\n\n";
cout << "You wait... the time is unknown\n\n";
}else {
cout << "\n\n\nThat answer is not a usable answer in this situation\n\n\n";
goto One; //I didn't know what else to use please critique!
}
cout << "\tYou hear footsteps faintly, distant but audible. They are getting louder and they\n";
cout << "suddenly stop. A door creaks open and you hear it touch a wall\n\n\n";

system ("pause");
return 0;
}

• This is a little biased, but I'd highly recommend that you check out my library for creating text-based adventure games, Cactus. It's written in Python, but it shouldn't be to difficult to translate. – Ethan Bierlein Oct 10 '15 at 1:57
• @EthanBierlein I downloaded your file, but I don't know how to install the python language and I'm not sure what translates to what and I am using Microsoft Visual Studio 2012. – Andrew Tew Oct 10 '15 at 2:37
• You need to add Cactus to your PYTHONPATH so it's importable. You can then either install Python 3.5 or the Python tools for Visual Studio. – Ethan Bierlein Oct 10 '15 at 2:39
• If you're looking for a system other than C, you should know that players like well established systems over homebrew parsers. You should look into Inform 7. – curiousdannii Oct 10 '15 at 3:13

I see you've ignored the advice from your previous question. To avoid duplication, I'm going to quote them:

Goto

At a first approximation, never use goto. It makes it more or less impossible to follow code. Without goto, you also don't need labels. Instead, just call different functions. Or keep an internal state machine. Or really any possible other solution. Code with goto like this is incredibly brittle - what if you want to add more states somewhere in between? Good luck keeping track of everything.

There many things here that can be improved. First off, let's tackle some best practices. Generally, doing stuff like this with system isn't very good:

system("pause");
system("cls");


To start off, system("pause"); is a bad way of "pausing" for user input. First off, there's a decently sized overhead just to execute a shell command, and doing this is rather insecure. If you really need to pause on user input, and ignore it, then just do something like this:

std::cin.get();


Secondly, putting anything like this at the top of your file is a bad idea:

using namespace std;


This pollutes your local namespace with everything in std, and it can lead to some name conflicts, especially if you're using a library like boost. There's a good reason it's named std and not standard. It's easier to prefix everything with std:: rather than standard::.

Now for some advice specific to this question:

First, all the newlines and tabs are quite noisy. You can consider putting it in a variable:

std::string tab(6, '\t');
std::cout << tab << "...";


Secondly, instead of your goto approach, it's more likely that you want a while loop instead. Some users insist that the while loop is a glorified goto, but without the negatives.

std::string answer;