I am trying to declare a global variable (Please don't say not to... I just wanna know how too) but I don't know where to put it or how to! Here is my code so far and the global variable I want to add but how can I do it?
#include <iostream>
#include <string>
usingnamespace std;
bool running = 1;
int userInput = 0;
int playerInfo[2];
void titleFunc();
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\n";
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;
}
if(playerLocation == 4) {
cout << "You have swam through a cave and found yourself on dry land... stil underground\n";
cout << "1: Walk forward\n";
cin >> userInput;
if(userInput == 1) playerLocation = 7;
}
if(playerLocation == 5) {
cout << "You find yourself at the edge of a cliff...\nYou jump off and grab hold of some vines and start swinging.\nYou grab onto another vine but it breaks and you fall to the ground with a hard thump!\n";
cout << "After laying on the ground for what felt like hours you finally find the strength to stand\n 1: Walk foward\n";
cin >> userInput;
if(userInput == 1) playerLocation = 12;
}
if(playerLocation == 6) {
cout << "You make it to the hole just in time before the lion swipes at you\nThere is a small hole to your right\n You manage to just fit through it and below you there is a drop into a cave\n";
cout << "1: Drop down\n";
cin >> userInput;
if(userInput == 1) playerLocation = 8;
}
if(playerLocation == 7) {
cout << "You have made your way through the cave and you see a fiery pit.\nYou search around a bit and you find a small opening\n";
cout << "Are you going to go through the small opening or be a badass and go across the fire\n 1: Small opening\n 2: Fiery pit\n";
cin >> userInput;
if(userInput == 1) playerLocation = 52;
elseif(userInput == 2) playerLocation = 9;
}
if(playerLocation == 8) {
cout << "You jump down through the hole and find yourself in a cave full of smoke\n";
cout << "You believe you are about to get overwealmed by the smoke so you start running\n 1: Run ahead\n";
cin >> userInput;
if(userInput == 1) playerLocation = 9;
}
if(playerLocation == 9) {
cout << "After adventuring forward for a while you find yourself with two paths.\n One is straight ahead and one is to your right.\n";
cout << "Do you turn right or keep going forward?\n 1: Turn right\n 2: Walk forward\n";
cin >> userInput;
if(userInput == 1) playerLocation = 53;
elseif(userInput == 2) playerLocation = 10;
}
}
return 0;
}
I havnt done the last half of the places or and mobs/weapons!
#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;