Completed Triple X

Since I completed my triple X game, I wanted to share it.

#include <iostream>

bool PlayGame(int Mult, int Add)
{
	int MagicA, MagicB, MagicC;
	std::cin >> MagicA >> MagicB >> MagicC;
	if (MagicA * MagicB * MagicC == Mult && MagicA + MagicB + MagicC == Add)
	{
		std::cout << "A cracking sound enters your ears and the door slowly opens!\n";
		return true;
	}
	else
	{
		std::cout << "You wait and wait, but nothing happens.\n"; 
		return false;
	}
}
void IntroLevel(int Mult,int Add)
{
	bool bResult;
	std::cout << "Opening your eyes, you find yourself on a bed inside a dark room.\nLooking around, you see a door.\nYou get up from the bed and walk up to the door.\nOn it, you find - what three numbers multiplied is "<<Mult<<" and what those three numbers added up is "<<Add<<"\nSpeak out your answer and if it's correct, the door will open.\nIf it's wrong, it will stay forever closed.\n";
	bResult = PlayGame(Mult,Add);
	if (bResult == false)
	{
		char RetryInput;
		std::cout << "Do you want to try again? (Y/N)\n";
		std::cin >> RetryInput; 
		RetryInput=tolower(RetryInput);
		if(RetryInput == 'y') IntroLevel(8, 6);
		else exit(1);
	}
}

void SubsequentLevels()
{
	int MagicA, MagicB, MagicC, Mult, Add;
	bool bResult;
	MagicA = rand() % 10;
	MagicB = rand() % 10;
	MagicC = rand() % 10;
	Mult = MagicA * MagicB * MagicC;
	Add = MagicA + MagicB + MagicC;
	std::cout << "Entering a new room you find a door.\nYou walk up to it and on it you find - what three numbers multiplied is " << Mult << " and what those three numbers added up is " << Add << "\nSpeak out your answer and if it’s correct, the door will open.\nIf its wrong, it will stay forever closed.\n";
	bResult = PlayGame(Mult, Add);
	if (bResult == false)
	{
		char RetryInput;
		std::cout << "Do you want to try again? (Y/N)\n";
		std::cin >> RetryInput;
		RetryInput = tolower(RetryInput);
		if (RetryInput == 'y') IntroLevel(Mult, Add);
		else exit(1);
	}
}
int main()
{
	IntroLevel(8,6);
	while (true) 
	{
		SubsequentLevels();
	}
}


I thought about implementing difficulty into the triple X game but decided against it.

1 Like

Amazing game! :fire: