#include <iostream>
#include <string>
usingnamespace std;
bool running = 1;
int userInput = 0;
int playerInfo[2];
void titleFunc();
int playerLocation = 0;
int main()
{
void titleFunc(); {
cout << "\t\t\t\t---Xeon---\n\n\n";
cout << "\t\t\t\t 1: Play\n";
cin >> userInput;
if(userInput == 1) {
void newGameFunc(); {
cout << "Welcome to Xeon!\nAn unexlored world full of adventurous paths and dangerous creatures!\n\n\n";
cout << "I am Zolo... The DragonBorn!\n\n\n";
cout << "Since you are a new comer to Xeon...\nCould you please tell me a little about yourself?\n\n";
cout << "Are you a boy or a girl?\n 1: Boy\n 2: Girl\n";
cin >> userInput;
playerInfo[0] = userInput;
cout << "And what kind of person are you?\n 1: Warrior\n 2: Archer\n 3: Thief\n 4: Scout\n 5: Mist\n";
cin >> userInput;
playerInfo[1] = userInput;
cout << "You suddenly feel a gentle breeze pushing you but you ignore it\n\n\n";
cout << "I thought I senced that in you! So now... Wait... Where are you going... What is happening!!\n\n\n";
cout << "You suddenly feel the breeze turning into a violent wind.\nYou look down at your hands but they start disapearing...\nEverything around you is becoming blury...\nYou suddenly feel very dizzy and your vision starts to fade...\nAnd then... Everything turns Black!\n\n\n";
playerLocation = 1;
}
}
else {
running = 0;
}
return 0;
}
while (running) {
if(playerLocation == 1) {
cout << "You look around and you are in a wild jungle.\n You walk for a bit and you find yourself at the edge of a cliff.\n Eveything looks amazing and tropical around you!\n You look down and there is a sky blue lake.\n";
cout << "Do you jump down or turn back?\n 1: Jump\n 2: Turn around and walk away\n";
cin >> userInput;
if(userInput == 1) playerLocation = 2;
elseif(userInput == 2) playerLocation = 3;
}
if(playerLocation == 2) {
cout << "You jumped down and landed with a big splash in the crystal water\n While you are in the water you see a small cave\n";
cout << "Do you enter the cave or do rise to the top of the water and walk away?\n 1: Enter the cave\n 2: Rise out of the water and walk away";
cin >> userInput;
if(userInput == 1) playerLocation = 4;
elseif(userInput == 2) playerLocation = 5;
}
if(playerLocation == 3) {
cout << "You walk away from the cliff and find yourself walking down a hill.\nYou suddenly stop and look behind you where you see a lion starting to chase you\nTo your right there is a shallow hole you could jump down that the lion couldnt fit\n OR you could run straight ahead to some vines hanging down infront of another cliff\n\n";
cout << "Do you go and hide in the hole or do you jump and swing on the vines?";
cin >> userInput;
if(userInput == 1) playerLocation = 6;
elseif(userInput == 2) playerLocation = 5;
}
}
return 0;
}
This code is complete and utter shit for a game because it doesn't have any error checking at all really and the logic is also broken. Please find a better tutorial.
I fixed your user input so it won't break. If you want to get fancy with your error statements then you will want to add some extra if statements or use while loops.
do
{
cout << "\t\t\t\t---Xeon---\n\n\n";
cout << "\t\t\t\t 1: Play\n";
cin >> userInput;
}
while (userInput != 1);
do
{
cout << "Welcome to Xeon!\nAn unexlored world full of adventurous paths and dangerous creatures!\n\n\n";
cout << "I am Zolo... The DragonBorn!\n\n\n";
cout << "Since you are a new comer to Xeon...\nCould you please tell me a little about yourself?\n\n";
cout << "Are you a boy or a girl?\n 1: Boy\n 2: Girl\n";
cin >> userInput;
}
while(userInput != 1 and userInput != 2);
playerInfo[0] = userInput;
do
{
cout << "And what kind of person are you?\n 1: Warrior\n 2: Archer\n 3: Thief\n 4: Scout\n 5: Mist\n";
cin >> userInput;
}
while(userInput < 1 or userInput > 5);