Hello all,
Here is my TripleX with the same code so far, just a different theme.
/
/ TripleX.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <iostream>
void PrintIntroduction(int Difficulty)
{
//Print opening messages to the player
std::cout << "\n\n You have discovered that a meteor has crashed near your home ";
std::cout << "\n\n There is a strange substance moving out from it devouring everyting in its path ";
std::cout << "\n\n There are 5 locations you must place a bomb, each closer to the original crash site";
std::cout << "\n\n You must enter the correct code to detonate the bomb to destroy the substance and the meteor \n\n" << Difficulty;
}
bool PlayGame(int Difficulty)
{
PrintIntroduction(Difficulty);
// Our declared integers and their values
const int CodeA = 4;
const int CodeB = 3;
const int CodeC = 2;
int CodeSum = CodeA + CodeB + CodeC;
int CodeProduct = CodeA * CodeB * CodeC;
// Stating our values
std::cout << std::endl;
std::cout << "\n+ There are 3 numbers in the code\n";
std::cout << "\n+ The codes add-up to:" << CodeSum;
std::cout << "\n+ The codes multiply to give:" << CodeProduct << std::endl;
//Store player guess
int GuessA, GuessB, GuessC;
std::cin >> GuessA >> GuessB >> GuessC;
int GuessSum = GuessA + GuessB + GuessC;
int GuessProduct = GuessA * GuessB * GuessC;
// Check if the plaer made the correct guess
if (GuessSum == CodeSum && GuessProduct == CodeProduct)
{
std::cout << "\n+ YOU DID IT!!! You set and detonated a bomb! Hurry and get to the next location!!\n";
return true;
}
else
{
std::cout << "\n+ You did not enter the code correctly!!! YOU HAVE BEEN CONSUMED BY THE SUBSTANCE!!\n\n";
return false;
}
}
int main()
{
int LevelDifficulty = 1;
const int MaxLevel = 5;
while (LevelDifficulty <= MaxLevel) // Loop game until all levels are completed
{
bool bLevelComplete = PlayGame(LevelDifficulty);
std::cin.clear(); // Clears any errors
std::cin.ignore(); // Discards the buffer
if (bLevelComplete)
{
++LevelDifficulty;
}
}
std::cout << "\n *** GREAT JOB!! YOU HAVE SAVED HUMANITY!!! *** \n";
return 0;
}