My own a little improved version of the unreal course c++ game

#include
#include
#include <windows.h>
#include <time.h>
#include <conio.h>
#include

int Level = 1;
int BadGuesses = 0;
int GoodGuesses = 0;
int MaxLevel = 10;
void Type(std::string Text, int Miliseconds)
{
int x = 0;
while (Text != ‘\0’)
{
std::cout << Text;
Sleep(Miliseconds);
x++;
}
}

void PrintIntro() {
Type(" Bad Guesses : “, 30);
std::cout << BadGuesses;
Type(” Good Guesses : “, 30);
std::cout << GoodGuesses << std::endl;
Type(” You’re breaking into a level ", 35);
std::cout << Level;

Type(" secure server room.", 35);

}

void PrintIntroduction()

{
Type(" Bad Guesses : “, 30);
std::cout << BadGuesses;
Type(” Good Guesses : “, 30);
std::cout << GoodGuesses << std::endl;
Type(” You’re a secret agent breaking into a level ", 35);
std::cout << Level;

Type(" secure server room.", 35);

}

void PlayGame()

{
if (Level == 1)
{
PrintIntroduction();
}
else
{
PrintIntro();
}

// Declare Codes and CodeSum / Product  (3 number)

int CodeA = rand() % 6 * Level;

int CodeB = rand() % 6 * Level;

int CodeC = rand() % 6 * Level;

const int CodeSum = CodeA + CodeB + CodeC;

const int CodeProduct = CodeA * CodeB * CodeC;

// Prints CodeSumSum And CodeProduct

Type("\n + The code has 3 numbers", 35);
Type("\n + The codes add up to: ", 35);
	std::cout << CodeSum;

Type("\n + The codes multiply to give: ", 35);
	std::cout << CodeProduct;

Type("\n + Enter the correct code to continue (Each number separated by a space)", 35);
Sleep(35);
	std::cout << "\n   ";
//Store's Guesses
int GuessA, GuessB, GuessC;
std::string strA, strB, strC;
std::cin >> strA >> strB >> strC;
Type("   You've entered: ", 35);
std::stringstream(strA) >> GuessA;
std::stringstream(strB) >> GuessB;
std::stringstream(strC) >> GuessC;
Type(strA, 35);
Type(strB, 35);
Type(strC, 35);
int GuessSum = GuessA + GuessB + GuessC;
int GuessProduct = GuessA * GuessB * GuessC;
//Check if guess == correct

if (GuessSum == CodeSum && GuessProduct == CodeProduct)

{
	Type("\n   The code is correct, administrator access given.", 35);
	Level++;
	GoodGuesses++;
	Sleep(200);
	system("CLS");

}

else

{
	BadGuesses++;
	Type("\n   The code is incorrect. you have ", 35);
	std::cout << 5 - BadGuesses;
	Type(" bad guesses left.", 35);
	Sleep(1000);
	system("cls");


}

}

int main()

{
srand(time(NULL));
system(“cmd /c “color 0A””);
while (Level <= MaxLevel && BadGuesses <= 5)

{

	PlayGame();

	std::cin.clear();

	std::cin.ignore();

}

return 0;

}

1 Like

Amazing job going above and beyond!

Privacy & Terms