Showcase- TripleX

1 Like

Great job sharing your work!

1 Like

Congrats!!!
I will just add my code here if that’s ok.

#include <iostream>
#include <ctime>

void PrintIntroduction(int Difficulty)
{
	// Game story
	std::cout << "\nYou are on your way to dicover great treasures.\n";
	std::cout << "You just have to crack the level " << Difficulty << " safe ...\n\n";
	std::cout << "Otherwise you might have to meet my little burning friend...\n";
	std::cout << "-----------evil maniacal laugh------------\n\n";
	std::cout << "Yup. No pressure.\n\n";
}

bool PlayGame(int Difficulty)
{
	PrintIntroduction(Difficulty);

	// variables declarations
	const int CodeA = rand() % Difficulty + Difficulty;
	const int CodeB = rand() % Difficulty + Difficulty;
	const int CodeC = rand() % Difficulty + Difficulty;

	const int CodeSum = CodeA + CodeB + CodeC;
	const int CodeProduct = CodeA * CodeB * CodeC;

	// Print sum and product to the terminal
	std::cout << "+There are 3 numbers in the combination.";
	std::cout << "\n+The numbers add-up to: " << CodeSum;
	std::cout << "\n+The numbers multiply to give: " << CodeProduct << "\n\n";

	// Player guesses
	int GuessA, GuessB, GuessC;
	std::cin >> GuessA >> GuessB >> GuessC;

	// Check if player correct
	int GuessSum = GuessA + GuessB + GuessC;
	int GuessProduct = GuessA * GuessB * GuessC;

	if (CodeSum == GuessSum && CodeProduct == GuessProduct)
	{
		std::cout << "\nLevel passed! New level with greater rewards await...\n\n";
		return true;
	}
	else
	{
		std::cout << "\nNumbers incorrect. Is it getting hot in here?\n";
		return false;
	}
}

// Numbers game
int main()
{
	// I only want to print the artwork (By JaL) once
	std::cout << "         .            )        )\n";
	std::cout << "                  (  (|              .\n";
	std::cout << "              )   )\/ ( ( (                \n";
	std::cout << "      *  (   ((  /     ))\\))  (  )    )\n";
	std::cout << "    (     \\   )\\(          |  ))( )  (|\n";
	std::cout << "    >)     ))/   |          )/  \\((  ) \\\n";
	std::cout << "    (     (      .        -.     V )/   )(    (\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";
	std::cout << "   \\    (    |  ||               ||  |   (  /\n";
	std::cout << "         \.  |  ||_             _||  |  /\n";
	std::cout << "           > :  |  ~V+-I_I_I-+V~  |  : (.\n";
	std::cout << "         (  \\:  T\\   _     _   /T  : ./\n";
	std::cout << "          \\  :    T^T T-+-T T^T    ;<\n";
	std::cout << "           \\..`_       -+-       _'  )\n";
	std::cout << " )           \\ . `--=.._____..=--'. ./         (\n";

	srand(time(NULL)); // creates a new random sequece based on time of day

	int LevelDifficulty = 1;
	const int MaxDifficulty = 5;

	while (LevelDifficulty <= MaxDifficulty) // Loop game until all levels as completed
	{
		bool bLevelComplete = PlayGame(LevelDifficulty);
		std::cin.clear(); // clear any input errors
		std::cin.ignore(); // discards the buffer

		if (bLevelComplete)
		{
			++LevelDifficulty;
		}
	}

	std::cout << "Congratulation, brave adventurer!\n\nYou passed all challenges.\nEnjoy your rewards.\n\n";

	return 0;
}
1 Like

Great job!! :fire:

Privacy & Terms