I'm extremely amateur when it comes to C++ in general, but I wanted to make a little "Pyramid Escape" text based game. I'm not done whatsoever but before I continue I want to see what I could possible do differently.
//
// main.cpp
// TextFiles
//
// Created by Neal Carico on 3/12/15.
// Copyright (c) 2015 Nedev. All rights reserved.
//
#include <iostream>
#include <cstdlib>
using namespace std;
int main(int argc, const char * argv[]) {
string start;
string restart;
string dead;
int turn1;
int turn2;
int turn3;
int turn4;
string decision1;
string decision2;
string decision3;
string decision4;
string decision5;
int random1;
int random2;
int random3;
while(restart != "dontrestart" || dead != "false"){
cout << "Welcome to the worlds largest pyramid. . . Type 'start' to enter or 'leave' to walk away..." << endl;
cin >> start;
///The Start
if (start == "start"){
///The main part of the game.
cout << "Oh no! The pyramid collapsed trapping you in. You are the only one alive. . ." << endl;
int score=0;
cout << "Okay. So you have two options here. . .Left(1) or right(2)?" << endl;
cin >> turn1;
if(turn1 == 2){
cout << "BAM! The roof collapsed over you and you die. Sad stuff" << endl;
cout << "Thank you for playing. Your score was " << score << endl;
exit(1);
}
cout << "You took the left path. And then BAM! The path to the right collapsed... lucky you." << endl;
score++;
cout << "There gold on the ground.. do you pick it up?[y/n]" << endl;
cin >> decision1;
if(decision1 == "y"){
cout << "You greedy bastard you. Lucky I like the irony and am not going to kill you in this instance... You find 10 gold." << endl;
score = score + 10;
}
cout << "You start heading forward again and come to another turn. But this time there are actually four options... :)" << endl;
random1 = rand() % 4 +1;
cout << "Your options are as follows. 1) Up to right 2)Down to right 3)Up to left and 4)Down to left. This one changes everytime ;). The random number is " << random1 << endl;
cin >> turn2;
if (turn2 == random1) {
cout << "BAM! The roof collapsed over you and you die. Sad stuff" << endl;
cout << "Thank you for playing. Your score was " << score << endl;
exit(1);
}
cout << "Sweet. You made it. There's a point." << endl;
score++;
cout << "Okay you start walking down the tunnel and something is moving in the distance. Do you approach it or head back to one of the other tunnels?(continue/return" << endl;
cin >> decision2;
if(decision2 == "continue"){
cout << "Yup, I'm not nice enough to give you a break 2 times in a row. Dead." << endl;
cout << "BLAAAHHHGGGG!! The figure is a crazed mummy who attacks you and you die. Sad stuff" << endl;
cout << "Thank you for playing. Your score was " << score << endl;
exit(1);
}
cout << "There is a screeching sound as you turn around." << endl;
score++;
///End of game stuff
}else if(start == "leave"){
cout << "You walked away and heard a huge BOOM and saw the pyramid collapsed trapping the tour group in. You are" <<
" one lucky person. Sure you lived, but you didn't even play the game. How lame.You can type 'restart' to try again, but you're always going to be a loser to me." << endl;
}else{
cout << "Error. Please type restart or 'dontrestart' (notice there are no spaces) to exit the game..." << endl;
}
cin >> restart;
if (restart !="restart"){
exit(1);
}
}
return 0;
}