#include
#include
void PrintIntroduction (int Difficulty)
{
// ASCI art here
std ::cout << R"(
, ,
,-{-
/
,-~ , \ {-~~-,
,~ , ,,-~~-,
,
,, { { } } }/ ; ,--/
\ \ / / }/ /,/
; ,-./ \ \ { { ( /,; ,/ ,/
; / } }
, -
-.___ / , ,/
,/
| ,,
~.___,---} / ,
,/ ,,;
{ { __ / ,/ ,
,;
/ \ \ _,,
{ ,{
,;
{ } } /~\ .-:::-. (–, ;\ ,}
,; \\._./ / /
, \ ,:::::::::, ~; \},/
,; ,-=-
-…-/.
._ ;:::::::::::; ,{ /
,; { / , ~ . ^
~\:::::::::::<<~>-,,
, -, ``,_ } /~~ .
. ~ , .~~\:::::::; _-~ ;__,
,-/
\ /~, . ~ , ’ , .
::::;<<<~``` ``-,,__ ; /
.\ /
. ^ , ~ , . . ~\~ \\,
,
/ , ,
. ~ , ^ ,
~ . . ~~~`, `-`--, \ / , ~ . ~ \ , ` . ^ ` , . ^ . , ` .`-,___,---,__
/
. ~ .
\ ~ , . ,
, . ~ ^ , . ~ , .~---,___ /
. , . ~ , \
~ , . ^ , ~ . , ~ . ^ , ~ .
-,
-Daniel Hunt-)" << '\n';
std::cout << std::endl;
//story of the game below
std::cout << “The code to the secret genetic enhancer mechanism was hidden in the safe…\n”;
std::cout << “It was the most secure safe of that era, it required an unprecedented effort to crack this code…\n”;
std::cout << “a team of 15 people attempted to open the safe, unfortunately the security mechanism killed the majority of them…\n”;
std::cout << “it was left to one individual to make one last attempt to open the safe…\n”;
std::cout << "You need to enter the correct level “<< Difficulty;
std::cout << " codes to continue…\n”;
//story ends here
}
bool PlayGame (int Difficulty)
{
PrintIntroduction (Difficulty);
//declare 3 number code
const int CodeA = rand() % Difficulty + Difficulty;
const int CodeB = rand() % Difficulty + Difficulty;
const int CodeC = rand() % Difficulty + Difficulty;
/*
This is
a multi-line
coment
*/
const int CodeSum = CodeA + CodeB + CodeC;
const int CodeProduct = CodeA * CodeB * CodeC;
// Print sum and product to the terminal
std::cout << std::endl;
std::cout << "There are 3 numbers in the code\n";
std::cout << "\nThe codes add up to: " << CodeSum;
std::cout << "\nThe codes multiply to give: " << CodeProduct;
std::cout << std::endl;
// Store player Guess
int GuessA, GuessB, GuessC;
std::cin >> GuessA >> GuessB >> GuessC;
// Check if players guess in correct
int GuessSum = GuessA + GuessB + GuessC;
int GuessProduct = GuessA * GuessB * GuessC;
if (GuessSum == CodeSum && GuessProduct == CodeProduct)
{
std::cout << "You have entered the correct code, try at the next level";
return true;
}
else
{
std::cout << "\nThis is the wrong code, the facility will now self destruct...\n";
std::cout << "But I will resurrect you to try again";
return false;
}
}
int main()
{
srand(time(NULL)); // create new random sequence based on time of day
int LevelDifficulty = 1;
int const MaxLevel = 5;
while (LevelDifficulty <= MaxLevel) // Loop game until all levels completed
{
bool bLevelComplete = PlayGame(LevelDifficulty);
std::cin.clear(); //Clears any errors
std::cin.ignore(); // Discards the buffer
if (bLevelComplete)
{
++LevelDifficulty;
}
}
std::cout << "\nCongratulations you have opened the safe!";
return 0;
}[quote=“Gavin_Milroy, post:1, topic:104962, full:true”]
Well done for completing Triple X!
How did you get on working with the modulus operator and generating your random number ranges?
I would LOVE to see the results of your final game!
How did you get on in this section? How hard you find the game to play?
[/quote]
progress so far!