How is your Triple X game looking?

#include <iostream>


void PrintIntroduction(int Difficulty)

{
     //Welcome message to the terminal
    std::cout <<"\n\nHello Dr.Gabe Newell Please have to hurry to come and we'll explain to you... \n";
    std::cout << "Take it short This Whole world is about going to end... \n";
    std::cout <<"Our last hope is to find the destination of our creator... \n";
    std::cout <<"and you are the only one who can do that... \n";
    std::cout <<"Here the code... and pls hurry up this is the before world end stage = " << Difficulty << std::endl << std::endl;
}
bool PlayGame(int Difficulty)
{
    PrintIntroduction(Difficulty);

    //Declare 3 number code
    const int CodeA = rand();
    const int CodeB = rand();
    const int CodeC = rand();

    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 code\n";
    std::cout << "\n+ The code add-up to : "<< CodeSum;
    std::cout << "\n+ The code Multiply is : "<< CodeProduct << std::endl;

    // Store player guess
    int GuessA, GuessB, GuessC;
    std::cout << "Please enter the Answer\n"; 
    std::cin >> GuessA >> GuessB >> GuessC;
    
    int GuessSum = GuessA+GuessB+GuessC;
    std::cout <<"\nYour Sum is : "<< GuessSum; 
    
    int GuessProduct = GuessA*GuessB*GuessC;
    std::cout <<"\nYour Product is : "<< GuessProduct; 
 
    //Check if the players guess is correct
    if(GuessSum == CodeSum && GuessProduct == CodeProduct)
    {
        std::cout << "\nGreat Job we got to another chance to make The world survie";
        std::cout << "\nHere Your another Code";
        return true;
    }
    else
    {
        std::cout << "You didn't make it... \n";
        std::cout << "This Whole World has been destr0y \n";
        std::cout << "sO. ... --- ... \n";
        std::cout << "tHIS iS Theeeeeeeeeeee eNd....... \n";
        std::cout << "Good Bye... \n";
        std::cout << "gsjajtwjg;skl as;vsvs.ge1g3g13er46 \n";
        std::cout << "Error Error Sever Shutdown \n";
        std::cout << "Deus ex machina :Prepare For Reset Protocol\n";
        return false;

    }
    
}

int main()
{
    int LevelDifficulty = 1;
    const int MaxDifficulty = 10;
    
    while(LevelDifficulty <= MaxDifficulty )//Loop game until all levels completed
    {
        bool  bLevelComplete = PlayGame(LevelDifficulty);
        std::cin.clear();//Clears any errors
        std::cin.ignore();//Discards the buffer

        if (bLevelComplete)
        {
            ++LevelDifficulty;
        }
                          
         std::cout << "Great Job You save the world\n";
    }
    return 0;
}
1 Like

Hey Guy’s :slight_smile: here is what I have so far, it might be basic, nothing added fancy besides what was shown. :slight_smile: but I’m proud of it.

#include

void PrintIntroduction(int Difficulty)

{

//Welcome Message

std::cout << "\n\n **   ___---___\n";

std::cout << " * .--         --.\n";

std::cout << " ./   ()      .-. .|)\n";

std::cout << "/   o    .   (   )  |)\n";

std::cout << "/ .           '-'    |)\n";

std::cout << "| ()    .  O         .)\n";



std::cout << "Greetings Fellow Astronaut, you are on your way through a level " << Difficulty;

std::cout << " asteroid field.\nYou need to calculate the correct number of asteroids in your way to countinue...\n\n";

}

bool PlayGame(int Difficulty)

{

PrintIntroduction(Difficulty);

//Declare 3 Number Code

const int CodeA = 4;

const int CodeB = 7;

const int CodeC = 1;

const int CodeSum = CodeA + CodeB + CodeC;

const int CodeProduct = CodeA * CodeB * CodeC;

// Print Sum & Product to the Terminal

std::cout << "+There are three digits to the number";

std::cout << "\n+The numbers add-up to: " << CodeSum;

std::cout << "\n+The numbers 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 player guess is correct

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

{

    std::cout << "\nWhaaaaahoooo, your on your way to Mars!";

    return true;

}

else

{

    std::cout << "\nWhoooa there space cadet, you almost crashed...Let's try that again!";

    return false;

}

}

int main()

{

int LevelDifficulty = 1;

const int MaxDifficulty = 99;

while (LevelDifficulty <= MaxDifficulty) //Loop game until all levels cleared

{

    bool bLevelComplete = PlayGame(LevelDifficulty);

    std::cin.clear(); //Clears Any Errors

    std::cin.ignore(); //Discards The Buffer

    if (bLevelComplete)

    {

        ++LevelDifficulty;

    }

    

}



std::cout << "After many wormholes and asteroid fields you finally made it...You landed on Mars."

return 0;

}

1 Like

My Triple X game

#include

void PrintIntroduction(int Difficulty)

{

std :: cout << std::endl << " You are a secret agent breaking into a level "<<Difficulty;

std :: cout << " secure server room...\n Enter the Code to enter...\n";

}

bool PlayGame(int Difficulty)

{

PrintIntroduction(Difficulty);

const int CodeA = 2;

const int CodeB = 3;

const int CodeC = 4;

const int CodeSum = CodeA+CodeB+CodeC;

const int CodeProduct = CodeA*CodeB*CodeC;

std::cout<<std::endl;

std::cout<<"+ There are three Codes"<<std::endl;

std::cout<<"+ Codes Add-up to : "<< CodeSum << std::endl;

std::cout<<"+ The Codes multiply to give : "<<CodeProduct<<std::endl;



int GuessA, GuessB, GuessC;

std::cin>>GuessA>>GuessB>>GuessC;

std::cout<<"You Enetered : "<<GuessA<<GuessB<<GuessC << std::endl;

int GuessSum = GuessA + GuessB + GuessC;

int GuessProduct = GuessA * GuessB * GuessC;

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

{

    if (Difficulty<5)

    {

    

    std::cout<<"+ Correct Password. Advanced to Next Level... +\n";

    std::cout<<"==================================================\n";    

    return true;

    }

}

else

{

    std::cout<<"+ Incorrect Password. You Lost. Try Agian +\n";

    std::cout<<"==================================================\n";

    return false;   

}    

}

int main()

{

int Level = 1;

int MaxLevel = 5;

while (Level<=MaxLevel)

{

    bool bLevelComplete=PlayGame(Level);    

    std::cin.clear();

    std::cin.ignore();

    if (bLevelComplete)

    {

        ++Level;

    }            

}

std::cout<<"+ Well done Agent. All files are collected. Now get out of there... +\n";

return 0;

}

1 Like

#include

void PrintIntroduction(int Difficulty)

{

// Print welcome messages to the terminal   

std::cout << "\n      (_)     (_)\n";   

std::cout << " _ __  _ _ __  _  __ _\n" ;

std::cout << "| '_ `| | '_ `| |/ _` |\n";

std::cout << "| | | | | | | | | (_| |\n";

std::cout << "|_| |_|_|_| |_| | __,_|\n";

std::cout << "             _/ |\n";      

std::cout << "            |__/\n\n"; 

std::cout << "You are a ninja at the entrance of a lavel " << Difficulty;

std::cout << " sacret tample... \nYou need to solve a puzzle in order to open the gate... \n\n";          

}

bool Playgame(int Difficulty)

{

PrintIntroduction(Difficulty);

const int LeverA = rand();

const int LeverB = rand();

const int LeverC = rand();

const int LeverSum = LeverA + LeverB + LeverC;

const int LeverProduct = LeverA * LeverB * LeverC;

// Print LeverSum and LeverProduct to the terminal

std::cout << "-> There are three levers with nine positions. Each position has a number from 1 to 9. ";

std::cout << "\n-> The position numbers add-up to: " << LeverSum;

std::cout << "\n-> The position numbers multiply to give: " << LeverProduct << std::endl;

// Store Player guessesssB

int GuessA, GuessB, GuessC;  

std::cin >> GuessA >> GuessB >> GuessC;

int GuessSum = GuessA + GuessB + GuessC;

int GuessProduct = GuessA * GuessB * GuessC;

// Check if the player is correct

if (GuessSum == LeverSum && GuessProduct == LeverProduct)

{

    std::cout << "\n*** Well done, Ninja! The gate level " << Difficulty;

    std::cout << " is open! ***\n";

    return true;

}

else

{

    std::cout << "\n*** Oh no, you got it wrong! Try again! ***\n";

    return false;

}

}

int main()

{

int LevelDifficulty = 1;

const int MaxDifficulty = 5;

while (LevelDifficulty <= MaxDifficulty) // 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; // Increase the level difficulty

    }

    

}

std::cout << "\n*** Congarulations! You passed all " << MaxDifficulty;

std::cout << " levels! ***\n";

return 0;

}


void Intro () 
{
std::cout << " \n Welcome Explorer, are you ready to have some fun today with Dora? \n \n";
std::cout << "                                          /////////// \n";
std::cout << "                                     ////            //// \n";
std::cout << "                                    |       @     @      |\n";
std::cout << "                                    ////       .     //// \n";
std::cout << "                                        //////////// \n \n";
}
bool PlayGame (int Difficulty) 
{
    Intro ();
 //Printing messages and performing breaks inbetween
    std::cout << "Dora the Explorer has ventured to the mountain of mathematics on a treasure hunting adventure. \n";
    
    std::cout << "She finds a vault that wants a certain amount of codes in order to open. \n";
    
    std::cout << "Can you help her by finding the correct codes? \n";
    
    std::cout << "There are 3 numbers in the code. \n";

    std::cout << "Right now you are on floor " << Difficulty << "\n";
    std::cout << std::endl;
   
    //Declaring numbers for variables
    const int FirstCode = rand();
    const int SecondCode = rand();
    const int ThirdCode = rand();

    //Sum & Product of Codes stored in variables
    const int CodeSum = FirstCode + SecondCode + ThirdCode;
    const int CodePro = FirstCode * SecondCode * ThirdCode;
    

    std::cout << "This is what the numbers add to: "  << CodeSum << "\n";
    std::cout <<"This is what the numbers multiply to: " << CodePro << "\n";

    int GuessA, GuessB, GuessC;

    std::cin >> GuessA >> GuessB >> GuessC;
    
    //Sum & Product of Guesses stored in variables.
    const int GuessSum = GuessA + GuessB + GuessC;
    const int GuessPro = GuessA * GuessB * GuessC;
   
    if (GuessSum == CodeSum && GuessPro == CodePro) {
        std::cout << "Hooray, we did it! Let's move on to the next safe. \n";
        return true;
    } else {
        std::cout << "That didn't work, but try again, you can do it! \n";
        return false;
    }

}

int main ()
{

   int LevelDifficulty = 1;
   const int MaxLevel = 7;

   while (LevelDifficulty <= MaxLevel) //Loop Game until max difficulty is reached.
   {
    bool bLevelComplete = PlayGame (LevelDifficulty);
   
   std::cin.clear ();
   std::cin.ignore();

   if (bLevelComplete)
   {
      ++LevelDifficulty;
   }
   
   }
    
    std::cout << "We got all the treasure and it's all thanks to you! Good Job! \n";
    return 0;

    //Can change variable name wherever it's used by clicking on the name, right click and then pick change all occurences.
}

My Code so far.

Screen Shot 1
Lines 1-30

!
Screen Shot 2
Lines 31- 47


Screen Shot 3
Terminal Play

TripleXShowcase2PT3 !

Intro Title

Playing a near-complete game
After getting my TripleX game to a near complete. I found myself unable to figure out the answer after level 2 without the use of a calculator. I found after the level the numbers themselves were harder to figure out as they got bigger. Ps. loving this course.

// TripleX.cpp.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <iostream>

int PrintIntroduction(int Difficulty)
{
    std::cout << R"(
                       mm                mm                             
@@@**@@**@@@           @@              *@@@                *@@@*   *@@* 
@*   @@   *@                             @@                  @@@m  m@   
     @@     *@@@m@@@ *@@@  *@@@@@@@@m    @@    mm@*@@         *@@m@*    
     !@       @@* **   @@    @@   *@@    !@   m@*   @@          @@@     
     !@       @!       !@    !@    @@    !@   !@******        m@**@@m   
     !@       @!       !@    !@    !@    !@   !@m    m        @   *@@m  
     !@       !!       !!    !@!   !!    !!   !!******        !!   !!!  
     !!       !:       !!    !@   !!!    :!   :!!            !!    *!!! 
   : :!::   : :::    : : :   :!: : :   : : :   : : ::      : : :    : ::
                             ::                                         
                           : : ::                                       
)" << '\n' << std::endl;
    std::cout << "You are a wizard trying to decrypt a level " << Difficulty;;

    std::cout << " spell from your spellbook . . .\n Enter the three digit code to unlock the spell . . .\n";


}

bool PlayGame(int Difficulty) 
{
    PrintIntroduction(Difficulty);
    int CodeA = rand();
    int CodeB = rand();
    int CodeC = rand();

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

    std::cout << "\nThere are 3 numbers in the code.\n";
    std::cout << "The codes add up to: " << CodeSum;
    std::cout << "\nThe codes can also be multiplied to equal: " << CodeProduct << std::endl;

    int GuessA, GuessB, GuessC;
    std::cin >> GuessA >> GuessB >> GuessC;


    int GuessSum = GuessA + GuessB + GuessC;
    int GuessProduct = GuessA * GuessB * GuessC;

    if (GuessSum == CodeSum && GuessProduct == CodeProduct)
    {
        std::cout << "\nYou entered the correct code! You can now try to unlock the next spell.";
        return true;
    }
    else
    {
        std::cout << "\nYou entered the wrong code! But don't worry, you can try again.";
        
        return false;
    }
}

int main()
{
    int LevelDifficulty = 1;
    const int MaxLevel = 5;
    while (LevelDifficulty <= MaxLevel)
    {
        bool bLevelComplete = PlayGame(LevelDifficulty);
        PlayGame(LevelDifficulty);
        std::cin.clear(); // clear any errors
        std::cin.ignore();// discards the buffer
        
        if (bLevelComplete) 
        {
            //increase the level difficulty
            ++LevelDifficulty;
        }
    }

    std::cout << "Congratulations! You have unlocked all the spells in this spell book.";

    return 0;
}

Taking in ASCII art into consideration, I had to create a new function PlayOpening() to play the ASCII art without putting it in PlayIntroduction(). I realized looping the game also loops the art so I had to avoid that by making a new function.



1 Like

Here is what I Came up with, took longer than I had hoped, but I kept tinkering with different things. I call it Covid-19, you need to create a vaccine using the proper code sequence, you are penalized for wrong attempts, and only have 10. It also keeps you informed of your progress as well as how many code sequences and attempts you have left. It is meant to be played from just double-clicking it and the text graphics are set to fit the default command window size perfectly, well at least the command window that opens for me…lol. It also has a simple cheat code display that can be enabled for testing…

/*******************************************************************************         First C++ Tutorial, TripleX
*******************************************************************************/

/*******************************************************************************        Preprocessor Directives
********************************************************************************/
#include <iostream>
#include <ctime>

/*******************************************************************************        Press Enter to Exit Game
********************************************************************************/
void ExitGame()
{
    std::cout << "                                             Press [ Enter ] to Exit.";
    std::cin.sync();
    std::cin.ignore();
}

/*******************************************************************************        Pause to Press Enter
********************************************************************************/
void Pause(int Difficulty)
{
    std::cout << "                                    Press [ Enter ] to ";
    std::cin.sync();
    std::cin.ignore();
}

/*******************************************************************************        Print Loser Game Message 
********************************************************************************/
void PrintLoseGame()
{
    std::cout << "\n\n\n\n\n";
    std::cout << "              ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
    std::cout << "              ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
    std::cout << "              ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
    std::cout << "              ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
    std::cout << "              ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\n";
    std::cout << "                                     No more attempts left you have failed!\n\n";
    std::cout << "                      Millions of people have died and the world economy has been shattered.\n"; 
    std::cout << "                               Covid-19 will continue to create world wide havoc.\n\n\n";                           
    std::cout << "              ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"; 
    std::cout << "              ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
    std::cout << "              ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
    std::cout << "              ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
    std::cout << "              ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\n\n\n\n\n\n";
}

/*******************************************************************************        Print Winner Game Message 
********************************************************************************/
void PrintSavedWorld()
{
    std::cout << "\n\n\n\n\n";
    std::cout << "                                               ++++++++++++++++++\n";
    std::cout << "                                        +++++++++++++++++++++++++++++++\n";
    std::cout << "                              +++++++++++++++++++++++++++++++++++++++++++++++++++\n";
    std::cout << "                     +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
    std::cout << "              ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\n";
    std::cout << "                                                   Great Job!\n\n";
    std::cout << "                 You have created a Covid-19 vaccine and saved the world of this terrible virus.\n\n\n";                           
    std::cout << "              ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"; 
    std::cout << "                     +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
    std::cout << "                              +++++++++++++++++++++++++++++++++++++++++++++++++++\n";  
    std::cout << "                                        +++++++++++++++++++++++++++++++\n";
    std::cout << "                                               ++++++++++++++++++\n\n\n\n\n\n\n";
}

/*******************************************************************************        Print Ascii Title Graphic and Story Line
********************************************************************************/
void PrintGameTitle()
{
    std::cout << "\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++";
    std::cout << "\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\n";     
    std::cout << "                         #######    #######  ##        ##  ##  ######          ##    ######          \n";
    std::cout << "                        ##     ##  ##     ##  ##      ##   ##  ##    ##       ###  ##    ##          \n";
    std::cout << "                        ##         ##     ##   ##    ##    ##  ##     ##       ##  ##    ##          \n";
    std::cout << "                        ##         ##     ##    ##  ##     ##  ##     ##  ###  ##    ######          \n";
    std::cout << "                        ##     ##  ##     ##     ####      ##  ##    ##        ##        ##          \n";
    std::cout << "                         #######    #######       ##       ##  #######        ####       ##          \n\n";                  
    std::cout << "                                 CAN YOU SAVE THE WORLD FROM THIS TERRIBLE PANDEMIC \n";
    std::cout << "\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++";
    std::cout << "\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"; 
    std::cout << "\n     You need to produce a vaccine for the Covid-19 virus. You must complete 5 code sequences correctly to succeed.\n";
    std::cout << "     As you complete the proper code numbers for each sequence you will progress toward the final Covid-19 vaccine.\n";
    std::cout << "      Every time you enter the wrong codes, you will be penalized an attempt. You have 10 attempts so be careful.\n\n";
}

/*******************************************************************************        Print Correct Screen
********************************************************************************/
void CorrectAnswer()
{
    std::cout << "\n";    
    std::cout << "                       ###    ###   ###   ###    ###    ###  #####     ###    ###   ###    ####   \n";
    std::cout << "                      #   #  #   #  #  #  #  #  #   #  #   #   #      #   #  #   #  #   #  #      \n";
    std::cout << "                      #      #   #  ###   ###   #####  #       #      #      #   #  #   #  ####   \n";
    std::cout << "                      #   #  #   #  # #   # #   #      #   #   #      #   #  #   #  #   #  #      \n";
    std::cout << "                       ###    ###   #  #  #  #   ###    ###    #       ###    ###   ####   ####   \n\n";
}

/*******************************************************************************        Print Wrong Screen
********************************************************************************/
void WrongAnswer()
{
    std::cout << "\n";    
    std::cout << "                 #  #   #   ###    ###   ###   ###    ###    ###  #####       ###    ###   ###    ####   \n";
    std::cout << "                 #  ##  #  #   #  #   #  #  #  #  #  #   #  #   #   #        #   #  #   #  #   #  #      \n";
    std::cout << "                 #  # # #  #      #   #  ###   ###   #####  #       #        #      #   #  #   #  ####   \n";
    std::cout << "                 #  #  ##  #   #  #   #  # #   # #   #      #   #   #        #   #  #   #  #   #  #      \n";
    std::cout << "                 #  #   #   ###    ###   #  #  #  #   ###    ###    #         ###    ###   ####   ####   \n\n";
}

/*******************************************************************************        Print Sequence Progress and Attemps Remaining Message
********************************************************************************/
void PrintSequenceProgress(int Difficulty, int RemainingLevels, int SolveAttempts)
{
    // **********  Sequence Progress Message 
    std::cout << "                                                    Sequence #"  << Difficulty << ".\n";
    std::cout << "                                                   +++++++++++++\n";
    std::cout << "\n                      Please enter your code numbers for sequence #" << Difficulty << " of the Covid-19 vaccine.\n";
    std::cout << "                          [[[ You have " << SolveAttempts << " attempts remaining and " << RemainingLevels << " sequences to solve ]]]\n\n";
}

/*******************************************************************************        Run PlayGame Function
********************************************************************************/
bool PlayGame(int Difficulty, int RemainingLevels, int SolveAttempts)
{
// **********  Declare and make Constant Variables
const int VacCodeA = rand() % Difficulty + rand() % 3 + Difficulty;
const int VacCodeB = rand() % Difficulty + rand() % 2 + Difficulty;
const int VacCodeC = rand() % Difficulty + rand() % 1 + Difficulty;
const int VacCodeSum = VacCodeA + VacCodeB + VacCodeC;
const int VacCodeProduct = VacCodeA * VacCodeB * VacCodeC;

if (Difficulty >= 1)  // Check if Difficulty is More or equal to Sequence/Level #1 Goto PrintSequenceProgress Function if True
    {
    PrintSequenceProgress(Difficulty, RemainingLevels, SolveAttempts);
    }

// **********  Begin Challenge
std::cout << "                                      There are 3 code numbers in sequence #" << Difficulty << "\n";
std::cout << "                                           The code numbers add up to: " << VacCodeSum << "\n";
std::cout << "                                           When multiplied they equal: " << VacCodeProduct << "\n\n";

// **********   Cheat Code Displayer, Remove "//" from begining of line below to enable 
//std::cout <<"                                                Cheat Codes [" << VacCodeA << " " << VacCodeB << " "<< VacCodeC << "]\n";

// **********  Declare Player Guess Variables with Player Input
int GuessA, GuessB, GuessC;
std::cout << "            Input your code numbers for sequence #" << Difficulty << " with a space between each code, then press Enter: ";  // Display entry request
std::cin >> GuessA >> GuessB >> GuessC;  // ********** Input and Store Guess Values

// **********  Set GuessSum and GuessProduct
int GuessSum = GuessA + GuessB + GuessC;
int GuessProduct =  GuessA * GuessB * GuessC;
    
// Check and Displayer Correct or Wrong Graphics
std::cout << "\n\n\n\n\n\n\n\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
if (GuessSum == VacCodeSum && GuessProduct == VacCodeProduct)  //  Check wether to Print CORRECT or WRONG on screen
    {
    CorrectAnswer();
    }
    else
        {
        WrongAnswer();
        }

std::cout << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"; 
std::cout << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\n"; 

// **********  Display Code Input as well as GuessSum and GuessProduct results
std::cout << " The numbers you entered for code sequence #" << Difficulty << " where [" << GuessA << "] ["<< GuessB << "] and ["<< GuessC << "]. " << "This sequence adds up to " << GuessSum << ", and multiplies to " << GuessProduct << ".\n\n";

// **********  Check and Display Player Result
if (GuessSum == VacCodeSum && GuessProduct == VacCodeProduct)
    {
        if (Difficulty < 5)  //  Check to make sure layer hasn't won last Difficulty before printing continued game play graphics and Returning TRUE
        {
            std::cout << "                      Good Job! Your one step closer to a Covid-19 vaccine and saving mankind.\n";
            std::cout << "                                        [[ Only "<< --RemainingLevels << " more sequences needed ]]\n\n";
            Pause(Difficulty);  // waite for "Enter" key pressed
            std::cout << "continue to sequence #" << ++Difficulty <<".\n\n";
            std::cout << "\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
            std::cout << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
            std::cout << "                                          +++++++++++++++++++++++++++++++\n";
            std::cout << "                                                +++++++++++++++++++\n";
            std::cout << "                                                       +++++\n\n\n";
            return true;        // Correct Entry Response and Return true bool
        }
        return true;        // Correct Entry Response and Return true bool
    }
    else  // Else, if Player gave wrong codes, print respounce and Return FALSE
        {
        std::cout << " Oh No! That code sequence is incorrect, the virus has possibly replicated to a different code sequence for sequence #" << Difficulty << "\n";
        std::cout << "                               Don't quit yet, the world needs you to figure this out!\n\n";
        Pause(Difficulty);  // waite for "Enter" key pressed
        std::cout << "retry sequence #"<< Difficulty << " again.\n\n";
        std::cout << "\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"; 
        std::cout << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\n\n\n\n\n";
        return false;   // Wrong Entry Response and Return false bool
        }

}

/*******************************************************************************        Main Source Code or Function
********************************************************************************/
int main ()
{
    PrintGameTitle();  //  Print Game Title
    srand(time(NULL)); // create new random sequence based on time of day
    
    // Initialize Progress Variables
    const int FinalLevel = 5;
    int LevelDifficulty = 1;
    int SolveAttempts = 10;
    int RemainingLevels = FinalLevel;

while (LevelDifficulty <= FinalLevel)  // ********** While Loop until all levels are complete
    {
    bool bLevelComplete = PlayGame(LevelDifficulty, RemainingLevels, SolveAttempts);  // **********  Check PlayGame LevelDifficulty
    std::cin.clear();  //  Clears any errors
    std::cin.ignore();  //  Discards the buffer
    
    if (bLevelComplete)  //  Check if bLevelComplete looped, if so increase LevelDifficulty, decrease RemainingLevels and increase SolveAttempts Variable
        {
        ++LevelDifficulty;
        --RemainingLevels;
        ++SolveAttempts; // Encrease SolveAttempts for correct code = No Penalty
        }
        
        --SolveAttempts; // Decrease SolveAttempts for wrong code   = Penalty
        
        if (SolveAttempts <= 0)  //  Check if SolveAttempts  is less or equal to 0, if so Print Lose Game Message and exit game with return 0,
            {
            PrintLoseGame();
            ExitGame();
            return 0;
            }
    }
    
// Print Winner Message
PrintSavedWorld(); 
ExitGame();

// exit Game
return 0;
}
1 Like

SO this is my code so far :slight_smile:

#include <iostream>

void PrintIntroduction()

{ 

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\n";



//Print story content for the game at start up on the terminal

   std::cout << "You wake up groggily coming to your senses slowly. You blink and take in your surroundings.\n\n";

   std::cout << "The room is a simple square in shape. There are no decorations and no furniture of any kind.\n\n";

   std::cout << "Instead of these usual objects, you see a series of dials built into the wall and a screen above each.\n\n";

   std::cout << "You attempt to open the door but there is no handle and bang as you might against the door it doesn't budge. It merely emits a dull metal thud and hurts your hands. The red lights blink at you apathetically.\n\n";

   std::cout << "There are 3 dials on each wall of the room with a number painted from 1-9. You also notice a door across from the middle set with 9 red squares on the surface.\n\n";

}

void PrintLevelIntroduction(int Difficulty)

{ 

   std::cout << "A voice suddenly resounds in the room. \"In order to escape this room you must solve each puzzle in numerical succession, each Dial getting harder with each success. Fail to answer a dial correctly and the consequences.... well... won't be flat-tering. MWahahahaha.\" and cuts off as quickly as it started.\n\n";

   std::cout << "The screen next to dial " << Difficulty;

   std::cout << " is lit and blinking...\n\n";

   std::cout << "Looks like you don't have much choice but to solve the puzzles if you hope to survive and eat those pancakes that you hope to avoid being turned into...\n\n";

}

bool PlayGame(int Difficulty)

{

   PrintLevelIntroduction(Difficulty);

   //declaring values for variables CodeA,CodeB,CodeC for the dials in the room

   const int CodeA = rand();

   const int CodeB = rand();

   const int CodeC = rand();

   const int CodeSum = CodeA + CodeB + CodeC;

   const int CodeProduct = CodeA * CodeB * CodeC;

   //Print the CodeSum and CodeProduct variable to the terminal

   std::cout << "+ There are 3 numbers in the code.";

   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;

   std::cout << "_____________________________________________________________________________________________________________________________________________\n";

   int GuessSum = GuessA + GuessB + GuessC;

   int GuessProduct = GuessA * GuessB * GuessC;

   // Check if the players Guess is Correct

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

   {

       std::cout << "\nYou hear a chime resound in the room and the screen you were working on turns off. You look around to see that Dial " << Difficulty;

       std::cout << " has lit up with the next puzzle to solve. You are one step closer to freedom. \n";

       

       return true;

   }

   else

   {

       std::cout << "\nThe ceiling groans and descends about a foot before ceasing. You have failed the dial but looks like you have a few attempts . The last thing you hear is laughing and the crunch of your body breaking...\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 << "     @@@@@@@@@@@#            @@@@@@@@@@@.     @@@@@                             \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 << "          &@@@@@@@@@@@@@@@@@                   @@@@@                            \n";

       std::cout << "         .@@@@@@@@@@@@@@@@@@.                  &@@@@.                           \n";

       std::cout << "       .&@@@@@@@@@@@@@@@@@%                    .@@@@@                           \n";

       std::cout << "        *@@@@@@@@@@@@(                                                          \n";

       std::cout << "             @#.                                                                \n";

      

       return false;

   }

}

int main()

{   

   int LevelDifficulty = 1;

   const int MaxDifficulty = 9;

   PrintIntroduction();

   while (LevelDifficulty <= MaxDifficulty) //loop the game until all levels completed

   {

       bool bLevelComplete = PlayGame(LevelDifficulty);

       std::cin.clear(); //Clears any errors

       std::cin.ignore(); // Discards the buffer

   if (bLevelComplete)

   {

       ++LevelDifficulty;

   }

   

   }

       std::cout << "\nThe door lights turn from red to green and the door releases a hiss releasing a sweet familiar scent. \n";

       std::cout << "You wipe the sweat off your brow and open the door as quickly as you can and enter a room with an exit sign and a table in the middle of the room with a stack of pancakes drenched in syrup. \n";

       std::cout << "Your stomach rumbles and your mouth drools at the sight and the smell of those round golden discs. You give in wanting some stress relief from the events you just went through and eat the stack with the utensils provided.\n";

       std::cout << "You head out the door marked exit carefully belly full. Having eaten your reward and earning your sweet freedom...\n\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 << "%@@         @@@,       ,%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#.       %@@(        .@@\n";

       std::cout << "(@@.          (@@@@%,                                       /@@@@@,          ,@@\n";

       std::cout << " *@@&              /@@@@@@@@@@&#*.             ,/%&@@@@@@@@@@.              @@@ \n";

       std::cout << "   ,@@@@                      ,(%&&@@@@@@@@@@@&&#/,                     ,@@@@   \n";

       std::cout << "       #@@@@&,                                                     (@@@@@*      \n";

       std::cout << "            ,@@@@@@@@%,                                   /@@@@@@@@&            \n";

       std::cout << "                     /%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&#,                    \n";

   return 0;

}

Here is my code. I have added a message that will tell you what will be your next level after message “you win”.
I introduced an if statement, so it will not say one level over the last level

// g++ triplex.cpp -o triplex ........... ./triplex
#include <iostream>

void PlayIntroduction(int Difficulty)
{
    std::cout << "\n\nYou are a secret agent breaking into a level " << Difficulty;
    std::cout << " secure room...\nEnter the correct code to continue...\n\n";
}
    
bool PlayGame(int Difficulty)
{
    PlayIntroduction(Difficulty);

    const int CodeA = rand();
    const int CodeB = rand();
    const int CodeC = rand();

    const int CodeSum = CodeA + CodeB + CodeC;
    const int CodeProduct = CodeA * CodeB * CodeC;
    
    // Prinst CodeSum and CodeProduct to the terminal
    std::cout << "+ There are 3 number in the code";
    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;
    //std::cout << "You entered: " << GuessA << GuessB << GuessC << std::endl;
    int GuessSum = GuessA + GuessB + GuessC;
    int GuessProduct = GuessA * GuessB * GuessC;

    // Check if the player guess is correct
    if (GuessSum == CodeSum && GuessProduct == CodeProduct)
    {
        std::cout << "\nYou win!";
        
        if (Difficulty<5)
        {
            std::cout << "\nYou will advance now to level: ";
            std::cout << Difficulty+1;
        }
        
        return true;
    }
    else
    {
        std::cout << "\nYou loose!";
        std::cout << "\nTry again level: " << Difficulty;
        return false;
    }

    std::cout << std::endl;
}


int main ()
{
    int const MaxLevel = 5;
    int LevelDifficulty = 1;

    while (LevelDifficulty <= MaxLevel) // Loop game until all level completed
    {
        bool bLevelComplete = PlayGame(LevelDifficulty);
        std::cin.clear();
        std::cin.ignore();

        if (bLevelComplete)
        {
                ++LevelDifficulty;
        }
        
        
    }
    std::cout << "\nYou have broken all the codes, Congratulations" << std::endl;
    return 0;
}

Hi Gavin! Here is how my code is looking so far.

#include <iostream>

void PrintIntroduction(int Difficulty)
{

    // Print messages to terminal
    std::cout << "\n\nYou are trapped in a cellar with a reverse bear trap on your head... ";
    std::cout << "\nThe trap has five locks that need to be opened\n";
    std::cout << "\nA message on a TV screen is telling you that you need to enter the correct codes to unlock it ...\n";
     std::cout << "Now you have to crack lock number " << Difficulty;
    std::cout << "\nOtherwise you will die!\n\n";
}

bool PlayGame(int Difficulty)
{

    PrintIntroduction(Difficulty);

    const int CodeA = 4;
    const int CodeB = 8;
    const int CodeC = 5;

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

    // Print CodeSum and CodeProduct to the terminal
    std::cout << "+ There are three numbers in the code\n";
    std::cout << "\n+ The codes add-up to: " << CodeSum;
    std::cout << "\n+ The codes multiply to: " << 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 player's guess is correct
    if (GuessSum == CodeSum && GuessProduct == CodeProduct)
    {
        std::cout << "\n\nLock opened\n";
        return true; 
    
    }
    else
    {
        std::cout << "Try again.";
        return false;
    }
}

int main() 
{

    int LevelDifficulty = 1;
    const int MaxDifficulty = 5;

    while (LevelDifficulty <= MaxDifficulty) //Loop game until all levels are completed
    {

        bool bLevelComplete = PlayGame(LevelDifficulty); 
        std::cin.clear(); // Clears any errors to input
        std::cin.ignore(); // Discards the buffer

        if (bLevelComplete)
        {
            ++LevelDifficulty;
        }
        
    }

    //Win message
    std::cout << "\nYou survived!\n";
    std::cout << "\nSome people are so ungrateful to be alive.\n";
    std::cout << "But not you ... \n";
    std::cout << "Not anymore.";
    
    return 0;   
}

Tell me what you think I put a lot of effort into it

Here’s my first post of code!

And the next section!

Hi Gavin and everyone on the course at the moment.

Here is my code so far. :slightly_smiling_face:`

// This programe is using UpperCamelCase for variable declarations this is in accordance with Unreal Engine's naming convention.

#include <iostream>// prerequisite code imported for it's functionality
                   // i.e. it's ability to facilitate certain tasks within a program.

void PrintIntroduction(int Difficulty)
{
    std::cout << "The Seven Crystals of Creation\n"; // Todo look for some ascii art or create some.
    if (Difficulty == 1)
    {
    std::cout <<  R"( 
                          /\\\\\\\\\\________/\\\\\\\\\\\______/\\\\\\\\\\\_______/\\\________\\\\_______/\\\\\\\\\\______/\\\\\\\\\
                         /\\\////////\\\_____\ \\\///////______\ \\\///////_______\ \\\______\\\\________\ \\\//////______\ \\\/////\\\\ 
                         \//\\\_____\///______\ \\\_____________\ \\\______________\ \\\____\\\\__________\ \\\____________\ \\\   \//\\\\ 
                           \////\\\____________\ \\\\\\\\\\\_____\ \\\\\\\\\\\______\ \\\  \\\\____________\ \\\\\\\\\\\____\ \\\\\\\\\\/
                               \////\\\_________\ \\\///////______\ \\\///////_______\ \\\\\\\______________\ \\\///////_____\ \\\//\\\\
                                   \////\\\______\ \\\_____________\ \\\______________\ \\\ //\\\\\ _________\ \\\____________\ \\\_//\\\\
                             /\\\______\//\\\_____\ \\\_____________\ \\\______________\ \\\_\////\\\\    ____\ \\\____________\ \\\__\///\\\\
                             \///\\\\\\\\\\\/______\ \\\\\\\\\\\_____\ \\\\\\\\\\\______\ \\\____\/////\\\\____\ \\\\\\\\\\_____\ \\\____\///\\\\
                                \///////////________\///////////______\///////////_______\///_________\////_____\////////// _____\///_______\////
                           
                    )"<< "\n";
    }
    std::cout << "+ You are on a quest to find all Seven of the 'Chrystals of Creation'\n";
    std::cout << "+ Welcome to level " << Difficulty, 
    std::cout << " Seeker.\n";
    std::cout << "+ To release the next crystal from 'The Vault of Testing' enter the correct 3 digit code";

}                     
bool PlayGame(int Difficulty) // The Game calculations are performed here.
{
    PrintIntroduction(Difficulty);
    
    int CodeA = rand();// This area is composed of declaration statements.
    int CodeB = rand();
    int CodeC = rand();

    int CodeSum = CodeA + CodeB + CodeC;
    int CodeProduct = CodeA * CodeB * CodeC;
    /*
    Finally, below, the statements to provide the final output are written.
    */

    std::cout << std::endl;// Expression statements. The..."do something" instructions.
    std::cout << "+ When added together the code numbers add up to: "<< CodeSum;// All statements, of any kind end with ';'
    std::cout << "\n+ When multiplied together the code numbers give a total of: "<< CodeProduct;

    //Store Player Guess

    int GuessA, GuessB, GuessC;
    std::cout << "\n+ What is the code, Seeker?\n";
    std::cin >> GuessA >> GuessB >> GuessC;
    //std::cout << "So...: " << GuessA << GuessB << GuessC;  
    //std::cout << " you say, hmmm?" << std::endl;

    int GuessSum = GuessA + GuessB + GuessC;
    int GuessProduct = GuessA * GuessB * GuessC;

    // A C++ IF statement is needed to sort correct answers from incorrect answers. 

    if (CodeSum == GuessSum && CodeProduct == GuessProduct) // Note double ampersand = AND operator.
    {
        std::cout << "Well done, Seeker, you have won the crystal!\n";
        return true;
    }
    else
    {
        std::cout << "\n***Unfortunately that is not the correct code, Seeker.***\n";
        std::cout << "              *** Please try again. *** \n\n";
        return false;
    }
}

int main()
{
    int LevelDifficulty = 1;
    int const MaxLevel = 7;
    while (LevelDifficulty <= MaxLevel) // This is the "Game Loop".
    {
        bool bLevelComplete = PlayGame(LevelDifficulty); // Level difficulty is incremented each time around the loop and passed to the parameter "Difficulty" within "PlayGame"
        std::cin.clear(); // Clears any errors
        std::cin.ignore(); // Discards the buffer
        if (bLevelComplete) // if the correct code is given by the player, LevelDifficulty is incremented by one ready for the next player guess.
        {
            ++LevelDifficulty;
        }
    }
    std::cout << "\n*** Congratulations, Seeker you have obtained all 7 Chrystals and can now rule all the Universes! ***\n";
    return 0;
}
1 Like

Privacy & Terms