Moving right along in the TripleX module. Here’s my progress so far for those of you perusing the forums:
#include
void TitleIntro()
{
// Display intro to the game
std::cout << "==================================================\n";
std::cout << "| | ^\\ | | | |\n";
std::cout << "| | | \\ | |__,,,--,,__| |\n";
std::cout << "| | / -', | __ : '''| \\ |_;;, |\n";
std::cout << "| | / , \\/ | | -__ | ' __|'\n";
std::cout << "| || , 4-, | ) __ | .;.(| |\n";
std::cout << "| ;|__ __ __ ' ' |(__/ .__)|-- ' (__\\_|_) |\n";
std::cout << "==================================================\n\n";
std::cout << "Your cat has been kidnapped by the group of booger eaters that stand about and fart on the corner!\n";
std::cout << "The cat's yowling leads you to their lair. They have your cat locked in a cage behind a series of metal gates! \n";
std::cout << "You see that the cage and the gates are protected by a devious keypad entry system! \n";
std::cout << "You must enter the correct codes at each barrier to get in and save your cat! \n\nBut first you rage kick in the first gate!\n";
}
bool PlayGame(int Difficulty)
{
// Declare 3 number code
const int CodeA = 2;
const int CodeB = 4;
const int CodeC = 6;
int CodeSum = CodeA + CodeB + CodeC;
int CodeProduct = CodeA * CodeB * CodeC;
// Display hints
std::cout << "\nRushing to the next keypad you see it is a level " << Difficulty;
std::cout << " lock!\n\n";
std::cout << "There are 3 numbers in the code.\n";
std::cout << "\n + Your gut tells you the 3 digit code adds up to: " << CodeSum;
std::cout << " and multiplied together equals: " << CodeProduct;
// Store Player inputs
int GuessA, GuessB, GuessC;
std::cout << "\n\n1st Keypad entry:";
std::cin >> GuessA;
std::cout << "2nd Keypad entry:";
std::cin >> GuessB;
std::cout << "3rd Keypad entry:";
std::cin >> GuessC;
// Declare sum and product of player guesses
int GuessSum = GuessA + GuessB + GuessC;
int GuessProduct = GuessA * GuessB * GuessC;
// Display the players input
std::cout << "\nYou quickly punch in: ";
std::cout << GuessA;
std::cout << " ";
std::cout << GuessB;
std::cout << " ";
std::cout << GuessC;
std::cout << "\n\nYou realize that the numbers you punched in add up to: " << GuessSum;
std::cout << ", and multiply together to equal: " << GuessProduct;
// Check players guess
if (GuessSum == CodeSum && GuessProduct == CodeProduct)
{
std::cout << "\n\nWith a satisfying 'click' the lock pops open!\n";
return true;
}
else
{
std::cout << "\n\nOH NO! The keypad beeps angrily and flashes red indicating you punched in the wrong code!";
return false;
}
}
int main()
{
TitleIntro();
int LevelDifficulty = 2;
const int MaxLevel = 6;
while (LevelDifficulty <= MaxLevel) //Loop the game until all levels are completed
{
bool bLevelComplete = PlayGame(LevelDifficulty);
std::cin.clear(); //Clears any errors
std::cin.ignore(); //Discards the buffer
if (bLevelComplete)
{
//Increase difficulty
++LevelDifficulty;
}
}
std::cout << "\nYou've done it! You reach inside the cage and claim your cat. Now run home before the Booger Eaters find out you snuck in!\n";
std::cout << "Good job! Thanks for playing!";
return 0;
}