#include <iostream>
#include <ctime>;
void PrintIntroduction()
{
//These are the parts of the code setting up the scene
std::cout << "You awaken in a dark room on a metal table.\n";
std::cout << "Though your head is pounding, you think you can understand words as if someone is talking.\n";
std::cout << "You need to get out of here! There are doors leading out but they're locked...\n";
std::cout << " ,---.\n";
std::cout << " / ,--. \\\n";
std::cout << " | ( () ) |\n";
std::cout << " \\ `--' /\n";
std::cout << " `-..-'\n\n";
}
void LevelIntro(int Difficulty)
{
std::cout << "This is door " << Difficulty << std::endl;
}
bool PlayGame( int Difficulty )
{
// proclaims combination numbers
int Num1 = rand() % Difficulty + Difficulty;
int Num2 = rand() % Difficulty + Difficulty;
int Num3 = rand() % Difficulty + Difficulty;
//a = 4;
int NumSum = Num1 + Num2 + Num3;
int NumProduct = Num1 * Num2 * Num3;
//b = 7;
LevelIntro(Difficulty);
//prints the sum and product variables
std::cout << "There are three numbers for the combination lock."
<< "\n";
std::cout << "The sum of the tree numbers for the combination is..." << NumSum << "\n";
std::cout << "The prduct of them is..." << NumProduct << "\n";
//player guesses
int Guess1, Guess2, Guess3;
std::cin >> Guess1 >> Guess2 >> Guess3;
int GuessSum = Guess1 + Guess2 + Guess3;
int GuessProduct = Guess1 * Guess2 * Guess3;
//checks the guess
if(GuessSum == NumSum && GuessProduct == NumProduct)
{
if(Difficulty < 10)
{
std::cout << "The lock clicks and it hits the ground with a clang!\n";
}
return true;
}
else
{
std::cout << "You feel the combination lock give you a painful shock, causing you to wince.\n\n";
return false;
}
}
int main()//This is the main body of my game and a work in progress
{
srand(time(NULL)); //creates new seed based off time of day
int LevelDifficulty = 1;
int const MaxLevel = 10;
PrintIntroduction();
while(LevelDifficulty <= MaxLevel)
{
bool bLevelComplete = PlayGame(LevelDifficulty);
std::cin.clear(); //clears the errors
std::cin.ignore(); //ignores the buffer
if(bLevelComplete)
{
++LevelDifficulty;
}
}
std::cout << "With one final click the last lock falls to the ground with a clang.\n";
std::cout << "You shield your eyes from the light but notice you aren't outside...\n";
std::cout << "\"Well, would you look at that, the little rat made it out.\" comes a voice from behind you.\n";
std::cout << "You look, wide-eyed at the silved maned man in front of you decorated in various medals.";
std::cout << "\"I guess that means phase one is finally done then.\" he \nsays before putting on a mask.\n";
std::cout << "Before you can say anything, the room begins to spin and you feel your consciousness start to fade...\n";
std::cout << "It looks like this is only the start of things to come but congratulations on making it this far...\n";
return 0;
}
Thoughts?