// Triple X Game - modified with 4 lives.
#include <iostream>
#include <ctime>
void PrintIntroduction()
{
// Intro
std::cout << "\n\n _________" << std::endl;
std::cout << " (=========)" << std::endl;
std::cout << " |=========|" << std::endl;
std::cout << " |====_====|" << std::endl;
std::cout << " |== | | ==|" << std::endl;
std::cout << " |= | _ | =|" << std::endl;
std::cout << " _ |=| ( ) |=|" << std::endl;
std::cout << " |=| |=|ALPHA|=| |=|" << std::endl;
std::cout << " |=| |=| 203 |=| |=|" << std::endl;
std::cout << " |=| |=| _ |=| |=|" << std::endl;
std::cout << " |=| |=| | | |=| |=|" << std::endl;
std::cout << " |=| |=| | | |=| |=|" << std::endl;
std::cout << " |=| |=| | | |=| |=|" << std::endl;
std::cout << " |=| || | | || |=|" << std::endl;
std::cout << " |=|| | | ||=|" << std::endl;
std::cout << " |=|NASA |_| NASA|=|" << std::endl;
std::cout << " |(_______________)|" << std::endl;
std::cout << " |=| |_|__|__|_| |=|" << std::endl;
std::cout << " |=| ( ) ( ) |=|" << std::endl;
std::cout << " |===| |===|" << std::endl;
std::cout << " ||||||| |||||||" << std::endl;
std::cout << " ------- -------" << std::endl;
std::cout << " (~~~) (~~~)" << std::endl;
std::cout << "\n\nSpace Shuttle Alpha 203 is about to launch, but Astronaut Bill is in the bathroom.\n";
std::cout << "You need to enter the correct codes to abort the launch.\n\n";
}
void PrintLevel(int Difficulty)
{
std::cout << "You are in Launch Sequencer Level " << Difficulty << std::endl;
std::cout << "\n";
}
bool PlayGame(int Difficulty)
{
PrintLevel(Difficulty);
//Number Setup
const int CodeA = rand() % Difficulty + Difficulty;
const int CodeB = rand() % Difficulty + Difficulty;
const int CodeC = rand() % Difficulty + Difficulty;
//Math
const int CodeSum = CodeA + CodeB + CodeC;
const int CodeProduct = CodeA * CodeB * CodeC;
//Print out the values
std::cout << "+ There are three numbers in this code.\n";
std::cout << "+ Adding the three numbers together get you: " << CodeSum;
std::cout << "\n+ Multiplying the three numbers together get you: " << CodeProduct;
std::cout << "\n\nType each number of the code seperated by a space.\n\n";
// Store player guesses.
int GuessA, GuessB, GuessC;
std::cin >> GuessA >> GuessB >> GuessC;
std::cout << std::endl;
int GuessSum = GuessA + GuessB + GuessC;
int GuessProduct = GuessA * GuessB * GuessC;
//Check if the answer is correct.
if (GuessSum == CodeSum && GuessProduct == CodeProduct)
{
std::cout << "You entered the correct code!\n";
return true;
}
else
{
return false;
}
}
int main() // Main portion of code.
{
PrintIntroduction();
srand(time(NULL));
int LevelDifficulty = 1;
const int MaxLevel = 5;
int Tries = 3;
while (LevelDifficulty <= MaxLevel)//Loop Game Until Levels are complete.
{
bool bLevelComplete = PlayGame(LevelDifficulty);
std::cin.clear(); //Clears any errors
std::cin.ignore(); //Discards the buffer
// Return values for getting an incorrect code and losing tries.
if (bLevelComplete == false && Tries == 0)
{
std::cout << "Wrong code, idiot!\n";
std::cout << "***Starting Launch Sequence***\n";
std::cout << "Shuttle Alpha 203 is launching unmanned.\n\n";
std::cout << "\n\n _________" << std::endl;
std::cout << " (=========)" << std::endl;
std::cout << " |=========|" << std::endl;
std::cout << " |====_====|" << std::endl;
std::cout << " |== | | ==|" << std::endl;
std::cout << " |= | _ | =|" << std::endl;
std::cout << " _ |=| ( ) |=|" << std::endl;
std::cout << " |=| |=|ALPHA|=| |=|" << std::endl;
std::cout << " |=| |=| 203 |=| |=|" << std::endl;
std::cout << " |=| |=| _ |=| |=|" << std::endl;
std::cout << " |=| |=| | | |=| |=|" << std::endl;
std::cout << " |=| |=| | | |=| |=|" << std::endl;
std::cout << " |=| |=| | | |=| |=|" << std::endl;
std::cout << " |=| || | | || |=|" << std::endl;
std::cout << " |=|| | | ||=|" << std::endl;
std::cout << " |=|NASA |_| NASA|=|" << std::endl;
std::cout << " |(_______________)|" << std::endl;
std::cout << " |=| |_|__|__|_| |=|" << std::endl;
std::cout << " |=| ( ) ( ) |=|" << std::endl;
std::cout << " |===| |===|" << std::endl;
std::cout << " ||||||| |||||||" << std::endl;
std::cout << " ------- -------" << std::endl;
std::cout << " (~~~) (~~~)" << std::endl;
std::cout << " (~~~) (~~~)" << std::endl;
std::cout << " (~~~) (~~~)" << std::endl;
std::cout << " (~~~) (~~~)" << std::endl;
std::cout << " (~~~) (~~~)\n\n\n";
std::cout << "There she goes!\n\n";
return 0;
}
if (bLevelComplete == false && Tries == 1)
{
std::cout << "Wrong code idiot!\n";
std::cout << "You have " << Tries;
std::cout << " try left.\n";
--Tries;
}
if (bLevelComplete)
{
++LevelDifficulty;
}
if (bLevelComplete == false && Tries >= 2)
{
std::cout << "Wrong code idiot!\n";
std::cout << "You have " << Tries;
std::cout << " tries left.\n";
--Tries;
}
if (bLevelComplete && LevelDifficulty <= MaxLevel)
std::cout << "But you're not done yet. Now entering Launch Sequencer " << LevelDifficulty;
std::cout << "\n\n";
std::cout << ".......\n\n";
}
std::cout << " . * .. . * *\n";
std::cout << " * * @()Ooc()* o .\n";
std::cout << " (Q@*0CG*O() ___\n";
std::cout << " |___________|/ _ |\n";
std::cout << " | | | | | | | |\n";
std::cout << " | | | | | | | |\n";
std::cout << " | | | | | | | |\n";
std::cout << " | | | | | | | |\n";
std::cout << " | | | | | | | |\n";
std::cout << " | | | | | |_| |\n";
std::cout << " | | | | |____/\n";
std::cout << " ||_|__|__|_||\n";
std::cout << " |_________|\n\n";
std::cout << "You have succesfully aborted the launch! Astornaut Bill owes you a beer!\n\n";
return 0;
}
2 Likes
I love the ASCII with the rocket!
1 Like