How is your Triple X game looking?

Here’s where I’m at! I first started this course pretty late at night so why I made it Bobby Hill themed I have no idea. Constructive criticism is always welcome! This is my first time coding anything so I’m not sure if it’s sloppy or not, but it does run.

I added some stuff such as:

  • Only giving out the ASCII art if the difficulty is at 1
  • Changing the access1.key number to reflect the difficulty
  • Giving out a congratulations message
#include <iostream>

void PrintIntroduction(int Difficulty)
{
    // Printing out Strings
    if (Difficulty == 1)
    {
        std::cout << "________  _______   ___  ___  ________  ___      ___ ___  ________  ___  ___  ________          ___  ________   _________  _______   ________  ________  ________ _________  ___  ___      ___ _______      ";
        std::cout << "\n|\\   __  \\|\\  ___ \\ |\\  \\|\\  \\|\\   __  \\|\\  \\    /  /|\\  \\|\\   __  \\|\\  \\|\\  \\|\\   __  \\        |\\  \\|\\   ___  \\|\\___   ___\\\\  ___ \\ |\\   __  \\|\\  __  \\|\\   ____\\\\___   ___\\\\  \\|\\  \\    /  /|\\  ___ \\     ";
        std::cout << "\n\\ \\  \\|\\ /\\ \\   __/|\\ \\  \\\\\\  \\ \\  \\|\\  \\ \\  \\  /  / | \\  \\ \\  \\|\\  \\ \\  \\\\\\  \\ \\  \\|\\  \\       \\ \\  \\ \\  \\ \\  \\|___ \\  \\_\\ \\   __/|\\ \\  \\|\\  \\ \\  \\|\\  \\ \\  \\___\\|___ \\  \\_\\ \\  \\ \\  \\  /  / | \\   __/|    ";
        std::cout << "\n \\ \\   __  \\ \\  \\_|/_\\ \\   __  \\ \\   __  \\ \\  \\/  / / \\ \\  \\ \\  \\\\\\  \\ \\  \\\\  \\ \\   _  _\\       \\ \\  \\ \\  \\ \\  \\   \\ \\  \\ \\ \\  \\_|/_\\ \\   _  _\\ \\   __  \\ \\  \\       \\ \\  \\ \\ \\  \\ \\  \\/  / / \\ \\  \\_|/__  ";
        std::cout << "\n  \\ \\  \\|\\  \\ \\  \\_|\\ \\ \\  \\ \\  \\ \\  \\ \\  \\ \\    / /   \\ \\  \\ \\  \\\\\\  \\ \\  \\\\\\  \\ \\  \\\\  \\|       \\ \\  \\ \\  \\\\ \\  \\   \\ \\  \\ \\ \\  \\_|\\ \\ \\  \\\\  \\\\ \\  \\ \\  \\ \\  \\____   \\ \\  \\ \\ \\  \\ \\    / /   \\ \\  \\_|\\ \\ ";
        std::cout << "\n   \\ \\_______\\ \\_______\\ \\__\\ \\__\\ \\__\\ \\__\\ \\__/ /     \\ \\__\\ \\_______\\ \\_______\\ \\__\\\\ _\\        \\ \\__\\ \\__\\\\ \\__\\   \\ \\__\\ \\ \\_______\\ \\__\\\\ _\\\\ \\__\\ \\__\\ \\_______\\  \\ \\__\\ \\ \\__\\ \\__/ /     \\ \\_______\\";
        std::cout << "\n    \\|_______|\\|_______|\\|__|\\|__|\\|__|\\|__|\\|__|/       \\|__|\\|_______|\\|_______|\\|__|\\|__|        \\|__|\\|__| \\|__|    \\|__|  \\|_______|\\|__|\\|__|\\|__|\\|__|\\|_______|   \\|__|  \\|__|\\|__|/       \\|_______|";
        std::cout << "\n\nYou are a hackerman trying to find out more info about the Residen Evil chapter for Dead by Daylight.";
    }
    std::cout << "\nYour current access level is: " << Difficulty;
    std::cout << "\nYou need to enter the correct passwords to get further access...\n\n";
}

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

    // Defining new integers
    const int CodeA = 4;
    const int CodeB = 8;
    const int CodeC = 16;

    // Defining integers that are additions / multiplications of the previous integers
    const int CodeSum = CodeA + CodeB + CodeC;
    const int CodeProduct = CodeA * CodeB * CodeC;

    // Printing out the integers
    std::cout << "- There are 3 numbers in the password";
    std::cout << "\n- The numbers add-up to: " << CodeSum;
    std::cout << "\n- The numbers mutliply 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;

    // Message for true / false guess
    if (CodeSum == GuessSum && CodeProduct == GuessProduct)
    {
        std::cout << "\nC:\\System\\BHVR\\access" << Difficulty << ".key found!";
        if (Difficulty != 5)
        {
            std::cout << "\nAccessing the next sublevel...\n";
        }
        else
        {
            std::cout << "\nExtracting String from Server...\n";
        }
        return true;
    }
    else
    {
        std::cout << "\nYou failed! Oh no :(\n";
        std::cout << "\nClearing BHVR Modem and all false attempts...\n\n";
        return false;
    }
}

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

    while (LevelDifficulty <= MaxDifficulty) // Loop until all levels are completed
    {
        bool bLevelComplete = PlayGame(LevelDifficulty);
        std::cin.clear(); // Clears anny errors
        std::cin.ignore(); // Discards the buffer

        if (bLevelComplete)
        {
            LevelDifficulty++;
        }
    }
    std::cout << "\nYou cracked into the buggy system, congratulations!\n";
    std::cout << "The Servers gave you this encrypted string:\n";
    std::cout << "aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1kUXc0dzlXZ1hjUQ==\n";
    std::cout << "\nExiting Linux KVM and resseting BHVR Access Modem...";
    std::cout << "\nC:\\Sys64\\kvmwin64 --stopallbhvrmodems\n";
    std::cout << "\nStopped all BHVR modems!\n";

    // Stopping the execution
    return 0;
}
#include <iostream>

int main()
{
    // Beginning storyline, prompting user for codes

    std::cout << "You are a secret agent breaking into a secure server room.";
    std::cout << std::endl;
    std::cout << "You need to enter the correct codes to continue ... " << std::endl;

    // Declaring three number code

    const int a = 4;
    const int b = 7;
    const int c = 8;

    // Print sum and product to the terminal

    std::cout << "The sum of the variables is: " << a + b + c << std::endl;
    std::cout << "The product of the variables is: " << a * b * c << std::endl;

    return 0;
}

When I ran the following code:

#include <iostream>

int main()

{

    std::cout << "Welcome To TripleX";

    std::cout << std::endl;

    std::cout << "You are a detective breaking into the secret sever rooms of a notorious cyberthief";

    std::cout << std::endl;

    std::cout << "You need to enter the correct password to continue...";

   int a = 4;

std::cout << a;

return 0;

}

The variable was not printed. What is the reason for this error?

My code up to half way through part 28

#include <iostream>

void PrintIntroduction(int Difficulty)
{
    /* std short for standard = Namespace
     - :: is a Scope Operator telling the compiler to chek for code inside the Namespace
     - Next comes what is being called from the name space
     - << this outputs what is to the right
     - "" text within will be printed to comand
     - std::endl tells the program to start a new line
    */
    std::cout << "\n\nI have trapped you in testing chamber " << Difficulty;
    std::cout << "\nI wil set you free once you have compleated all the codes\n";
    std::cout << "If you fail, be prepared for the consequences ... \n\n";
}  

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

    /*const stops you from being able to change the info
    - int is any whole number
    - Next the name is stated and what info is carried with the name*/
    const int CodeA = 4;
    const int CodeB = 7;
    const int CodeC = 3;

    //For maths +-/* Plus,Minus,Divide,Tmes
    const int CodeSum = CodeA + CodeB + CodeC;
    const int CodeMulti = CodeA * CodeB * CodeC;

    //You can add << std::endl to the end of a line of script
    std::cout << "* There are 3 numbers in the code";
    std::cout << "\n* The numbers add-up to: " << CodeSum;
    std::cout << "\n* The numbers also multiply to: " << CodeMulti << std::endl;

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

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

    //Check if player won or lost
    if (GuessSum == CodeSum && GuessMulti == CodeMulti)
    {
        std::cout << "\nYou guessed corectly, let's see if your luck continues\n\n";
        return true;
    }
    else
    {
        std::cout << "\nYou Failed\n\n";
        return false;
    }

}


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

    while (LevelDifficulty <= MaxLevel) // Loop the game till all levels are completed
    {
        bool bLevelComplete = PlayGame(LevelDifficulty);
        std::cin.clear();
        std::cin.ignore();

        if (bLevelComplete)
        {
            ++LevelDifficulty;
        }
        
    }
    
    std::cout << "Congratulations, you may leave";
    //return will end your script
    return 0;
}
/* When changeing code right click and "change all occurrences"
 * std::cout << "he said: \"Hello, World!\"";  <--- The \ allow the "" to be printed
 * std::cout << "Hello, World!\n"; <--- The \n inserts a new line
*/

  • My Code :slight_smile:

  • My Program :slight_smile:

No creativity, : D

#include <iostream>

void PrintIntroduction(int Difficulty)
{
    std::cout <<"\n\nYou are a Thief, Breaking into a Security level " << Difficulty;
    std::cout <<" Bank\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 <<"                 /   |   |c           |                    \n";
    std::cout <<"                /    /    )  GoT  x    |                   \n";
    std::cout <<"                |   /|    |c     / \\.-  |                  \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 <<"                  /      |  8888|___/888888.               \n";
    std::cout <<"                 |_      :)88888888888888888888.           \n";
    std::cout <<"                /` `-----'  `Y88888888888888888            \n";
    std::cout <<"                |____|         `88888888888P'              \n";
    std::cout <<"                                                           \n";
    std::cout <<"                                   from https://ascii.co.uk/art \n\n";
    std::cout << "You need to figure out the code to open this vault.....\n\n";
}

bool PlayGame(int Difficulty)
{
    //this will print messages in the terminal
    PrintIntroduction(Difficulty);

    // declare 3 number code
    const int NumberA = rand();
    const int NumberB = rand();
    const int NumberC = rand();
    
    int CodeSum = NumberA + NumberB + NumberC;
    int CodeProduct = NumberA * NumberB * NumberC;

    std::cout << "There are 3 nmumbers in the code";
    std::cout << "\n*The numbers in the code add up to: " << CodeSum;
    std::cout << "\n*The numbers in the code also has a Product of: " << 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 players guess is correct
    if (GuessSum==CodeSum && GuessProduct==CodeProduct)
    {
        std::cout << "\nYou got the money!, get ready for our next heist";
        return true;
    }
    else
    {
        std::cout << "\nYou failed, and got caught. Now your team is highly disappointed";
        std::cout << "\n\nRetry?";
        return false;
    }
}


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

    while (LevelDifficulty <= MaxDifficulty) //Loop the game until it finishes
    {
        bool bLevelComplete = PlayGame(LevelDifficulty);
        std::cin.clear();//Clears any error
        std::cin.ignore();//Disregards the buffer

        if (bLevelComplete)
        //increase level difficulty
        {
            ++LevelDifficulty;
        }
        
    }

    std::cout << "\nYou got the money and you successfully robbed 5 banks!";
    return 0;
}

#include

void PrintIntroduction(int Difficulty)

{

// Print the Welcome message

std::cout <<"\n\nYou are a secret agent trying to enter a Level " << Difficulty;

std::cout <<" server room....\nEnter the correct code to continue...\n";

}

bool PlayGame(int Difficulty)

{

PrintIntroduction(Difficulty);

// Declare 3 number code

const int CodeA= 2;

const int CodeB = 4;

const int CodeC = 6;

//Print sum and product to the terminal

const int CodeSum = CodeA + CodeB + CodeC;

const int CodeProduct = CodeA * CodeB * CodeC;

std::cout << "* There are 3 numbers in the code\n";

std::cout << "* The sum of all three codes: "<< CodeSum;

std::cout << "\n* The product of codes is: "<< CodeProduct << std::endl;



// Store Player Guess

int GuessA, GuessB, GuessC;

//Ask for players guess

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

int GuessProduct = GuessA*GuessB*GuessC;

int GuessSum = GuessA + GuessB + GuessC;

// Check if the players answer is correct or not

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

{

    std::cout << "\nBravo Agent, You got it, Access Granted!";

    return true;

}

else

{

    std::cout << "\nAccess Denied...Incorrect Code, TRY AGAIN..!";

    return false;

}

}

int main()

{

int LevelDifficulty = 1;

int const MaxLevel = 5;

while (LevelDifficulty <= MaxLevel)

{

    bool bLevelComplete = PlayGame(LevelDifficulty);

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

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

    

    if (bLevelComplete)

    {

        ++LevelDifficulty;

    }

    

}

std::cout << "\nYou are Master, Congratulations You Successfully Got the Access to FINAL SERVER 
                      ROOM!!";

return 0;

}


Looking pretty good. Fair and balanced.

Before of the explanation of “less than or equal to” i’ve come up with a different version to solve the problem, obviously yours is cheaper in therms of time, but atleast i’ve tryed ^_^"
int main()
{
int LevelDifficulty = 1;
const int MaxDifficulty = 5;

while (true) //Loop game until all levels are completed
{
	bool bLevelComplete = PlayGame(LevelDifficulty);
	std::cin.clear(); //Clears any errors
	std::cin.ignore(); //Discard the buffer

	if (bLevelComplete)
	{
		++LevelDifficulty;
	}
	if (LevelDifficulty==MaxDifficulty)
	{
		return 0;
	}
}

return 0;

}

My Code:
#include

using namespace std;

void PrintIntroduction(int Difficulty)

{

//Print welcome message to the terminal

cout<<"\n\nYou are a secret agent breaking into a Level "<<Difficulty<<" secured server room..."<<endl;

cout<<"Enter the correct code to continue"<<endl;

}

bool PlayGame(int Difficulty)

{

PrintIntroduction(Difficulty);

//Declaring 3 number code

const int CodeA = 4;

const int CodeB = 3;

const int CodeC = 2;

cout<<" + There are three codes"<<endl<<endl;

const int CodeSum = CodeA+CodeB+CodeC;

const int CodeProduct = CodeA*CodeB*CodeC;

//Print the sum and product

cout<<" + The codes add to give: "<<CodeSum<<endl;

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



//Taking Guess values from the player

int GuessA, GuessB, GuessC;

cin>>GuessA;

cin>>GuessB;

cin>>GuessC;



//Evaluating the values entered by the player

int GuessSum = GuessA + GuessB + GuessC;

int GuessProduct = GuessA * GuessB * GuessC;

//Printing the Sum and Product

cout<<"The sum of the entered values is: "<<GuessSum<<endl;

cout<<"The product of the entered values is: "<<GuessProduct<<endl;

//Checking 

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

{

    cout<<"You win!\n";

    return true;

}

else

{

    cout<<"You lost! Better luck next time.\n";

    return false;

    

}

}

int main()

{

int LevelDifficulty = 1;

const int MaxDifficulty = 5;

while (LevelDifficulty<=MaxDifficulty)

{

    bool bLevelComplete =  PlayGame(LevelDifficulty);

    cin.clear();                //clears the error

    cin.ignore();               //ignores the buffer

    if (bLevelComplete)

    {

        ++LevelDifficulty;       

    }

} 

cout<<"\n\n Malware updated successfully. \n Now run away from here\n";

return 0;

}

Output:

my code so far, i love the course and i have a lot of fun while coding,
The story is an among us related story.

#include <iostream>

void PrintIntroduction(int Difficulty)
{
    //Print welcome messages to the ternimal
    std::cout << "\n\nYou are at elecrical, lost and scared but you need to do the task\n";
    std::cout << "for every task you do right you will eject an impostor, but every time you fail you will eject a fellow crewmate\n";
    std::cout << "you are curently in level: " << Difficulty;
}

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 ternimal
    std::cout << "\n\n-Every task you do will need to have 3 digits of code";
    std::cout << "\n-The code adds up to: " << CodeSum;
    std::cout << "\n-The code multiply to give: " << CodeProduct;
    std::cout << std::endl;

    //Store player guess input
    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 == CodeSum && GuessProduct == CodeProduct)
    {
        //win
        std::cout << "\n\nyeah, that is what i call a win\n";
        std::cout << "a SUSSY IMPOSTOR just got thrown out\n";
        std::cout << "you are as good as i thought, keep up the nice work\n";
        return true;
    }
    else
    {
        //lose
        std::cout << "\n\nreally, i thought you were better than this\n";
        std::cout << "a fellow crewmate has just been thrown in the deep vacuum of space...\n";
        return false;
    } 
}


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

        if (bLevelComplete)
        {
            ++LevelDificulty;
        }
        
    }
    
    std::cout << "\n***congratulations you are the best crewmate in the world :)***\n";

    return 0;
}

I wanted to continue this course lately and this is what I’ve done so far :smiley:

#include <iostream>

void PrintIntroduction(int Difficulty) 
{
    // Introduces the game to the player
    std::cout << "\n\nYou are a secret agent breaking into a level " << Difficulty;
    std::cout << " secure server room. \nYou need to enter the correct codes to continue...\n\n";
}

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

    // Declare 3 numbers code
    const int CodeA = 4;
    const int CodeB = 3;
    const int CodeC = 2;

    const int CodeSum = CodeA + CodeB + CodeC;
    const int CodeProduct = CodeA * CodeB * CodeC;
    
    // Print sum and product to the terminal
    std::cout << std::endl;
    std::cout << "+ There are 3 numbers in the code";
    std::cout << "\n+ The codes add-up to: " << CodeSum;
    std::cout << "\n+ The codes multiplies by: " << CodeProduct << std::endl;

    // Store the 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*** You win ! Up to the next level ! ***\n";
        return true;
    } 
    else
    {
        std::cout << "\n*** You lose... Let's retry ! ***\n";
        return false;
    }
}

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

    while (LevelDifficulty <= MaxLevel) // Loop game until all levels completed
    {
        bool bLevelComplete = PlayGame(LevelDifficulty);
        std::cin.clear(); // Clears any erros
        std::cin.ignore(); // Discards the buffer

        if (bLevelComplete) 
        {
            ++LevelDifficulty;
        }
    }

    std::cout << "You made it ! Congratulations and thank you for playing !";

    return 0;
}


1 Like

Great job everyone :clap::clap::clap:

1 Like

I have added a new feature of the trial to make it more serious .(limited trial or it will restart from level 1)




1 Like

#include

void PrintIntroduction (int Difficulty)

{

// Back Story (Expression Statements)

std:: cout << "\n\n You are trying to get aimbot and hack into a Level " << Difficulty;

std:: cout << " Fortnite server \n Get the numbers correct to get in...\n";

}

bool PlayGame(int Difficulty)

{

PrintIntroduction(Difficulty);

//Declare Code

const int CodeA = 4;

const int CodeB = 2;

const int CodeC = 1;

const int CodeSum = CodeA + CodeB + CodeC;

const int CodeProduct = CodeA * CodeB * CodeC;

// Printing Sum and Product

std:: cout  << "There are three numbers in the code\n";

std:: cout  <<"*When you add these numbers, you get ";

std:: cout  << CodeSum <<"*\n";

std:: cout  << "*When you multiply these numbers, you get ";

std:: cout  << CodeProduct<< "*\n\n";

//Showing User Input

int GuessA, GuessB, GuessC;

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

int GuessSum = GuessA + GuessB + GuessC;

int GuessProduct = GuessA * GuessB * GuessC;



//Showing if User is Right or Wrong

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

{

    std:: cout << "Nice Job, On to Level "<< Difficulty << "!";

    return true;

}

else

{

    std:: cout <<"Oh, that's not quite right. Try again";

    return false;

}

}

int main()

{

int LevelDifficulty = 1;

int const MaxDifficulty = 10;

while (LevelDifficulty <= MaxDifficulty)

{

bool bLevelComplete = PlayGame(LevelDifficulty);

std::cin.clear();// Clears all the errors

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

if (bLevelComplete)

{

   ++LevelDifficulty;

}

}

std::cout << "Congratulations, You have successfully infiltrated the Servers!";

return 0;

}

1 Like
#include <iostream>
using namespace std;

void PrintIntroduction()
{
    cout << " _______  _                  _______      _       \n"
    "(_______)| |                ( ______)    (_)  \n"
    " _       | | _    ____       \\ \\   ____   _   ____   ____ \n"
    "| |      | || \\  / _  )       \\ \\ |  _ \\ | | / ___) / _  )\n"
    "| |_____ | | | |( (/ /    _____) )| | | || || |    ( (/ /\n"
    " \\______)|_| |_| \\____)  (______/ | ||_/ |_||_|     \\____)\n"
    "                                  |_|                     \n";

     //Create the setting for the puzzle
    cout << "You enter The Spire and find a door on the other end. \n"; 
    cout << "You must enter the correct numbers to move through the next door... \n";
}

void PrintLevel(int Difficulty)
{
    cout << "\nRoom "<< Difficulty << endl;
}

bool PlayGame(int Difficulty, int MaxDifficulty)
{
    
    //Declare 3 number code
    const int CodeA = rand();
    const int CodeB = rand(); 
    const int CodeC = rand(); 

    //Calculate the sum and product 
    const int CodeSum = CodeA + CodeB + CodeC;
    const int CodeProd = CodeA * CodeB * CodeC;

    //Print sum and product to terminal
    cout << endl;
    cout << "+ There are 3 numbers in the code \n";
    cout << "+ The sum of the numbers is: " << CodeSum << endl;
    cout << "+ The product of the numbers is: " << CodeProd << endl;
    
    int GuessA, GuessB, GuessC;

    cout << "\n Enter your guess:\n";

    // Store player guess
    cin >> GuessA >> GuessB >> GuessC;
    
    
    int GuessSum = GuessA + GuessB + GuessC;
    int GuessProd = GuessA * GuessB * GuessC;

    // Check guess 
    if (GuessSum == CodeSum && GuessProd == CodeProd)
    {
        if (Difficulty < MaxDifficulty)
        {
        cout << "\nThe floor rumbles beneath you.\nThe door slides open...\n";
        }
        else 
        {
            cout << "\nCongratulations, you have made it through " << MaxDifficulty << " rooms of The Spire."
            "\nYou return to the spaceship to take a rest.\n";
        }
       return true;
    }
    else
    {
        cout << "\nTitanium blades shoot out across the room dicing you to pieces.\nDr. Trintigant puts you back together.\n"
        "Try Again.\n";
        return false;
    }
}


int main()
{   
    int LevelDifficulty = 1;
    const int MaxDifficulty = 2;
    PrintIntroduction();
    bool bLevelComplete = true;

    while (LevelDifficulty <= MaxDifficulty) // Loop game until all levels are completed
    {
        PrintLevel(LevelDifficulty);
        bLevelComplete =  PlayGame(LevelDifficulty, MaxDifficulty);
        cin.clear(); // Clears any errors
        cin.ignore(); // Discards the buffer
        
        if (bLevelComplete)
        {
            ++LevelDifficulty; 
        }
        
    }


    return 0;      
}
 _______  _                  _______      _       
(_______)| |                ( ______)    (_)
 _       | | _    ____       \ \   ____   _   ____   ____ 
| |      | || \  / _  )       \ \ |  _ \ | | / ___) / _  )| |_____ | | | |( (/ /    _____) )| | | || || |    ( (/ / 
 \______)|_| |_| \____)  (______/ | ||_/ |_||_|     \____)                                  |_|
You enter The Spire and find a door on the other end. 
You must enter the correct numbers to move through the next door...

Room 1

+ There are 3 numbers in the code
+ The sum of the numbers is: 12
+ The product of the numbers is: 48

 Enter your guess:
2 4 6

The floor rumbles beneath you.
The door slides open...

Room 2

+ There are 3 numbers in the code
+ The sum of the numbers is: 12
+ The product of the numbers is: 48

 Enter your guess:
2 4 6

Congratulations, you have made it through 2 rooms of The Spire.
You return to the spaceship to take a rest.
1 Like
#include <iostream>

void PrintIntroduction(int Difficulty)
{
    std::cout << "       __\n";                                                                                      
    std::cout << "      /_/l\n";                                                                                      
    std::cout << "      : : :\n";                                                                                      
    std::cout << "       ; ; ;\n";                                                                                     
    std::cout << "       : : :\n";                                                                                     
    std::cout << "        L ; ;  __.-._.-+. \n";                                                                       
    std::cout << "       /.\"^.:.L.' .^-.  \\`. \n";                                                                     
    std::cout << "      :`.`. \"/\\ /.-. `. \\ \\ \n";                                                                    
    std::cout << "      ;\\ \\ ` ;-.y(_.-\\  \\ `.`. \n";                                                                  
    std::cout << "      :   _. ;;  `    \\  \\. `-\\ \n";                                                                 
    std::cout << "       \\ T :: :=,   ,=^\\  \"-._;          __..------.._ \n";                                         
    std::cout << "       /;:-'; ; `._L.--^.     .-""-.`.   \\     ""--..         \n";                           
    std::cout << "      : :_.': :           ;/     \\   /      \\ \\   ;          ""--._\n";                              
    std::cout << "      ;  T   \\ \\  s      /:.---.  ;_/    `-._; ;  :     ______    \"-.      ___ \n";                 
    std::cout << "     :   :\\   \\ `.-=^\" .:-\"    _\\   \\_.      : :  _:.--\".-\"  .T\"---:-.\"\"--\"\"\\  \"\"-.   \n";           
    std::cout << "     ;    \\   \"-.\\__.:'      /-'. ; ;    _. ; ;  /   -'    '    .- \\        ;     \"-._.-\"\"\"\"\"-,\n"; 
    std::cout << "     :     ;\\     `..'      .'    \\: ;      / / .'               )   ;  __  /         T        :\n"; 
    std::cout << "      ;      `,     \\    .-\"       ;/\"---\" /.' /                 `- /\"\"\"  \"\"---\"\"\"\"----..___..-'\n"; 
    std::cout << "      :    .-\" `.      .'.-\\      / \"\"----\"\"\"\"^-.._              .-\" \n";                        
    std::cout << "       \\_.'      \"._.-\"-..-'`-..-'                 \"\"--..__..--\"\"\";\n"; 

    std::cout << "\nYou  are an super-secret agent on level " << Difficulty;
    std::cout << " going to kill Tomb Raider\nFor that you need a bit of knowledge in mathematics and to find a code\n";
}

bool PlayGame(int Difficulty)
{
    // PrintIntroduction(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;

    // print CodeSum and CodeProduct to the terminal
    std::cout << "\n(^~^) There are 3 numbers that you must figure out";
    std::cout << "\n(^~^) The codes give the sum: " << CodeSum;
    std::cout << "\n(^~^) And the product: " << CodeProduct;
    std::cout << std::endl << std::endl;

    // store player int guess
    int GuessA, GuessB, GuessC;
    std::cin >> GuessA >> GuessB >> GuessC;

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

    // see if the player guess is correct or not
    if (GuessSum == CodeSum && GuessProduct == CodeProduct){
        std::cout << "\nlol u did it correct, nois\n";
        return true;
    }
    else{
        std::cout << "\nbro Tomb Raider saw you :/ Try again..\n";
        return false;
    }
}

int main() 
{
    int LevelDifficulty = 1;
    const int MaxDifficulty = 3;

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

        std::cin.clear();
        std::cin.ignore();

        if (bLevelComplete){
            // increase the level difficulty
            ++LevelDifficulty;
        }
    }

        std::cout << "you passed the game HoOhOoHoHOOHOhoohOho";

    return 0;
}

Here is what my Take on Triple X looks like so far:

#include

void PrintIntroduction(int Difficulty)

{

std::cout << "\n\n A master rogue, you are in the midst of the most difficult heist of your career thus far- cracking the level " << Difficulty;

std::cout << "lock on the personal vault safe of the Tyrant Duke Orcanzer...\nEnter the correct combination to continue...\n\n";

}

bool PlayGame(int Difficulty)

{

//Print welcome messages to terminal

PrintIntroduction(Difficulty);

//Declare 3 number code

const int CombinationA = 4;

const int CombinationB = 2;

const int CombinationC = 7;

const int CombinationSum = CombinationA + CombinationB + CombinationC;

const int CombinationProduct = CombinationA * CombinationB * CombinationC;

//Print CombinationSum and CombinationProduct to terminal

std::cout << "\n+ The safe has a 3 number combination";

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

std::cout << "\n+ The combination numbers multiply to: " << CombinationProduct << 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's guess is correct

if (GuessSum == CombinationSum && GuessProduct == CombinationProduct)

{  

    std::cout <<"\n The first lock slips silently open and your fingers move nimbly on to the next.";

    return true;

}

else

{

    std::cout << "\n You've missed the mark! You check your surroundings and try again.";

    return false;

}

}

int main()

{

int LevelDifficulty = 1;

const int MaxLevel = 25;

while (LevelDifficulty <= MaxLevel) //Lop 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\n As the midnight moves softly toward twilight the final lock clicks into place and the door swings open;\n"

"you pocket all contained within, and slip out the window and into the night, a newly crowned Legend.\n\n";

return 0;

}

Privacy & Terms