This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-10-03 21:12:50

johndo77
Scratcher
Registered: 2010-07-30
Posts: 1000+

C++ Code

Here is the C++ code of this project.

#include <iostream>
#include <string>
using namespace std;

int main()
{    string arr [10];
    int game=1, l=0, area=100, bottle=0, shovel=0, potion=0, milk=0, keygrave=0, keybasement=0, bone=0, courage=0, hole=0, bottlehad=0, win=0;
    string a;
    cout << "You wake up outside, surrounded by tall green trees. A little too green..." << endl; // Intro   
       

                                                //BEGIN 1 //
    while (area==100)
    {
        cout << "\n Should you inspect a tree?" << endl;
       
        cin >> a;
        if (a=="yes") // YES
        {
            cout << "\n WOW!!!!! A big hairy foot with claws stepped where you woke up! Good thing you  moved! Do you still want to inspect the tree?" << endl;
            area=101;
        }
        else if (a=="no") // NO
        {
            cout << "\n You got stepped on by a big hairy foot! THE END" << endl;
            area=-100;
        }
        else if (a=="xyzzy") // NO
        {
            cout << "\n Hehehe... \n\n funny." << endl;
        }
        else
        {
            cout << " " << endl;
        }
    }
                                                    // BEGIN 2 //

    while (area==101)
    {
        cin >> a;

        if (a=="yes") // YES
        {
            cout << "\n It's really tall and thin. It waves in the wind. What do you think it is?" << endl;
            area=102;
        }
        else if (a=="no") // NO
        {
            cout << "\n You stand the in the the forest, your life has no purpose. THE END" << endl;
            area=-100;
        }
        else
        {
            cout << " " << endl;
        }
    }

                                            //FRONT YARD GRASS RIDDLE//
    while (area==102)
    {
        cin >> a;
        cout << "\n It's grass! How did it get so big? Or how did you get so small!" << endl;
        cout << "\n You find a notebook. Type 'add' to add a note to your notepad or type 'check'  to look at your notes. Don't waste the notes! The notebook only has 10 lines.   Make sure each note is written in one word." << endl;
        area=0;
    }

       
    while (area != -100)
    {   
                                            //FRONT YARD 0//

        while (area==0)
        {
            cout << "\n You can go north to the house or east to a tree." << endl;
            cin >> a;

            if (a=="add" && l<10) // add one note
            {
                cout << "\n write your note." << endl;
                cin >> arr [l];
                l=l+1;
            }
            else if (a=="check") // print all notes
            {
                cout << "  1." << arr[0] << "  2." << arr[1] << "  3." << arr[2] << "  4." << arr[3] << "  5." << arr[4] << "  6." << arr[5] << "  7." << arr[6] << "  8." << arr[7] << "  9." << arr[8] << "  10." << arr[9] << endl;
            }
            else if (a=="north") // Go to house
            {
                if (shovel==1)
                {
                    cout << "\n You're in the foyer. You can go: North, up, down, or south." << endl;
                    area=2;
                }
                else if (shovel==0)
                {
                    cout << "\n You walk through the open door.\n There is a shovel.\n Type 'shovel' to pick it up. You can go: North, up, down, or south" << endl;
                    area=2;
                }
            }
            else if (a=="east") // Go to tree
            {
                if (bottlehad==0)
                {
                    cout << "\n There is a bottle of milk that is your size. Type 'bottle' to pick it up. You  can go: West" << endl;
                    area=1;
                }
                else if (bottlehad==1)
                {
                    cout << "\n you are near a tree. You can go: West." << endl;
                    area=1;
                }
                else
                {
                    cout << " " << endl;
                }
            }
            else if (a=="dig" && shovel==1) // Dig
            {
                if (hole==0)
                {
                    cout << "\n You found a bone!" << endl;
                    bone=1;
                    hole=1;
                }
                else if (hole==1)
                {
                    cout << "\n You killed yourself trying to dig nothing. THE END" << endl;
                    area=-100;
                }
            }
            else if (a=="add") // NO MORE NOTES
            {
                cout << "\n Sorry, no more notes!" << endl;
            }
            else
            {
                cout << " " << endl;
            }           
        }
                       
                                        // TREE 1//


        while (area==1)
        {
            cin >> a;

            if (a=="add" && l<10) // add one note
            {
                cout << "\n write your note." << endl;
                cin >> arr [l];
                l=l+1;
            }
            else if (a=="check") // print all notes
            {
                cout << "  1." << arr[0] << "  2." << arr[1] << "  3." << arr[2] << "  4." << arr[3] << "  5." << arr[4] << "  6." << arr[5] << "  7." << arr[6] << "  8." << arr[7] << "  9." << arr[8] << "  10." << arr[9] << endl;
            }
            else if (a=="bottle") // Pick up bottle
            {
                if (bottlehad==0)
                {
                    cout << "\n This is cat milk!" << endl;
                    bottle=1;
                    milk=1;
                    bottlehad=1;
                }
                else if (bottlehad==1)
                {
                    cout << "\n The bottle has been taken already." << endl;
                }
            }
            else if (a=="west") // Go to front yard
            {
                cout << " " << endl;
                area=0;
            }
            else if (a=="dig" && shovel==1) // Dig
            {
                cout << "\n You tapped into a secret testing facility FILLED with...\n\n\n DONUTS SHAPED LIKE WAFFLES!!!!!!! \n\n\n\n YOU WIN!!!" << endl;
                area = -1;
            }
            else if (a=="add") // NO MORE NOTES
            {
                cout << "\n Sorry, no more notes!" << endl;
            }
            else
            {
                cout << " " << endl;
            }
        }
       
                                            // HOUSE FOYER 2//
       
        while (area==2)
        {
            cin >> a;

            if (a=="add" && l<10) // add one note
            {
                cout << "\n write your note." << endl;
                cin >> arr [l];
                l=l+1;
            }
            else if (a=="check") // print all notes
            {
                cout << "  1." << arr[0] << "  2." << arr[1] << "  3." << arr[2] << "  4." << arr[3] << "  5." << arr[4] << "  6." << arr[5] << "  7." << arr[6] << "  8." << arr[7] << "  9." << arr[8] << "  10." << arr[9] << endl;
            }
            else if (a=="shovel") // get shovel
            {
                if (shovel==0)
                {
                    cout << "\n You can now dig holes in the ground!" << endl;
                    shovel=1;
                }
                else if (shovel==1)
                {
                    cout << "\n You already took the shovel." << endl;
                }
            }
            else if (a=="up") // go to attic
            {
                if (courage==0)
                {   
                    cout << "\n You are to scared to enter the attic!" << endl;
                }
                else if (courage==1 && keybasement==0)
                {
                    cout << "\n You burst the door open, launching it across the room! \n You pick up a key! You can go: down." << endl;
                    area=5;
                    keybasement=1;
                }
                else if (courage==1 && keybasement==1)
                {
                    cout << "\n There is nothing in here anymore." << endl;
                    area=5;
                }
            }
            else if (a=="down") // Go to front yard
            {
                if (keybasement==0)
                {   
                    cout << "\n The basement is locked." << endl;
                }
                else if (keybasement==1)
                {
                    cout << " There is a giant shrink ray and a mad scientist!\n Type 'shrink' to shrink him and unsrink yourself!" << endl;
                    area=6;
                }
            }
            else if (a=="south") // Go to front yard
            {
                cout << " " << endl;
                area=0;
            }
            else if (a=="north") // Go to front yard
            {
                cout << "\n You're in the kitchen. There is a bowl on the floor. If you have milk you      should pour it! You can go: East or south" << endl;
                area=3;
            }
            else if (a=="add") // NO MORE NOTES
            {
                cout << "\n Sorry, no more notes!" << endl;
            }
            else
            {
                cout << " " << endl;
            }
        }

                                        // KITCHEN 3//

        while (area==3)
        {
            if (bone==1 && bottle==1)
            {
                cin >> a;

                if (a=="add" && l<10) // add one note
                {
                    cout << "\n write your note." << endl;
                    cin >> arr [l];
                    l=l+1;
                }
                else if (a=="check") // print all notes
                {
                    cout << "  1." << arr[0] << "  2." << arr[1] << "  3." << arr[2] << "  4." << arr[3] << "  5." << arr[4] << "  6." << arr[5] << "  7." << arr[6] << "  8." << arr[7] << "  9." << arr[8] << "  10." << arr[9] << endl;
                }
                else if (a=="pour" && bottle==1) // Pour milk
                {
                    cout << "\n A dog comes to drink the milk. \n\n 'RUFF!' \n\n Translation: Find my bone! I lost it!" << endl;
                    bottlehad = 1;
                    bottle = 0;
                }
                else if (a=="south") // Go to foyer
                {
                    if (shovel==1)
                    {
                        cout << "\n You're in the foyer. You can go: North, up, down, or south." << endl;
                        area=2;
                    }
                    else if (shovel==0)
                    {
                        cout << "You are in the foyer.\n There is a shovel.\n Type 'shovel' to pick it up. You can go: North, up, down, or south" << endl;
                        area=2;
                    }
                }
                else if (a=="east") // Go to Grave
                {
                    if (keygrave=0)
                    {
                        if (courage==0)
                        {
                            cout << "\n The door is locked!" << endl;
                            courage=1;
                            area=4;
                        }
                    }
                    if (keygrave=1)
                    {
                        if (courage==0)
                        {
                            cout << "\n You entered a grave! who has a door to a grave in there kitchen? Anyway, the   sight of dead people built up your courage!" << endl;
                            courage=1;
                            area=4; // Get in grave
                        }
                        else if (courage==1)
                        {
                            cout << "\n You're so courageous that you burn the grave... \n \n and the house. THE END" << endl;
                            area = -100; // Burn Grave
                        }
                    }
                }
                else if (a=="add") // NO MORE NOTES
                {
                    cout << "\n Sorry, no more notes!" << endl;
                }
                else
                {
                    cout << " " << endl;
                }
            }
            else if (bone==1 && bottle==0 && bottlehad==1)
            {
                cout << "\n 'RUFF' \n \n Translation: Thank you! here is a key!" << endl;
                keygrave=1;
                bone=0; // give bone
            }
            else
            {
                {
                cin >> a;

                if (a=="add" && l<10) // add one note
                {
                    cout << "\n write your note." << endl;
                    cin >> arr [l];
                    l=l+1;
                }
                else if (a=="check") // print all notes
                {
                    cout << "  1." << arr[0] << "  2." << arr[1] << "  3." << arr[2] << "  4." << arr[3] << "  5." << arr[4] << "  6." << arr[5] << "  7." << arr[6] << "  8." << arr[7] << "  9." << arr[8] << "  10." << arr[9] << endl;
                }
                else if (a=="pour" && bottle==1 && bone==0) // Pour milk
                {
                    cout << "\n A dog comes to drink the milk. \n\n 'RUFF!' \n\n Translation: Find my bone! I lost it!" << endl;
                    bottlehad = 1;
                    bottle = 0;
                }
                else if (a=="south") // Go to foyer
                {
                    if (shovel==1)
                    {
                        cout << "\n You're in the foyer. You can go: North, up, down, or south." << endl;
                        area=2;
                    }
                    else if (shovel==0)
                    {
                        cout << "You are in the foyer.\n There is a shovel.\n Type 'shovel' to pick it up. You can go: North, up, down, or south" << endl;
                        area=2;
                    }
                }
                else if (a=="east") // Go to Grave
                {
                    if (keygrave=0)
                    {
                        if (courage==0)
                        {
                            cout << "\n The door is locked!" << endl;
                            courage=1;
                            area=4;
                        }
                    }
                    if (keygrave=1)
                    {
                        if (courage==0)
                        {
                            cout << "\n You entered a grave! who has a door to a grave in there kitchen? Anyway, the   sight of dead people built up your courage!" << endl;
                            courage=1;
                            area=4; // go to grave
                        }
                        else if (courage==1)
                        {
                            cout << "\n You're so courageous that you burn the grave... \n \n and the house. THE END" << endl;
                            area = -100; // burn grave
                        }
                    }
                }
                else if (a=="add") // NO MORE NOTES
                {
                    cout << "\n Sorry, no more notes!" << endl;
                }
                else
                {
                    cout << " " << endl;
                }
            }
        }
            }
                                            // GRAVE 4//

        while (area==4)
        {
            cin >> a;

            if (a=="add" && l<10) // add one note
            {
                cout << "\n write your note." << endl;
                cin >> arr [l];
                l=l+1;
            }
            else if (a=="check") // print all notes
            {
                cout << "  1." << arr[0] << "  2." << arr[1] << "  3." << arr[2] << "  4." << arr[3] << "  5." << arr[4] << "  6." << arr[5] << "  7." << arr[6] << "  8." << arr[7] << "  9." << arr[8] << "  10." << arr[9] << endl;
            }
            else if (a=="west") // Go to kitchen
            {
                cout << "\n You're in the kitchen. You can go: East or south." << endl;
                area=3;
            }
            else if (a=="add") // NO MORE NOTES
            {
                cout << "\n Sorry, no more notes!" << endl;
            }
            else
            {
                cout << " " << endl;
            }
        }
       
                                                    // ATTIC 5 //
       
        while (area==5)
        {
            cin >> a;

            if (a=="add" && l<10) // add one note
            {
                cout << "\n write your note." << endl;
                cin >> arr [l];
                l=l+1;
            }
            else if (a=="check") // print all notes
            {
                cout << "  1." << arr[0] << "  2." << arr[1] << "  3." << arr[2] << "  4." << arr[3] << "  5." << arr[4] << "  6." << arr[5] << "  7." << arr[6] << "  8." << arr[7] << "  9." << arr[8] << "  10." << arr[9] << endl;
            }
            else if (a=="down") // Go to foyer
            {
                cout << "\n You're in the foyer. You can go: North, up, down, or south." << endl;
                area=2;
            }
            else if (a=="add") // NO MORE NOTES
            {
                cout << "\n Sorry, no more notes!" << endl;
            }
            else
            {
                cout << " " << endl;
            }
        }
       
                                                // BASEMENT 6 //
       
        while (area==6)
        {
            cin >> a;

            if (a=="add" && l<10) // add one note
            {
                cout << "\n write your note." << endl;
                cin >> arr [l];
                l=l+1;
            }
            else if (a=="check") // print all notes
            {
                cout << "  1." << arr[0] << "  2." << arr[1] << "  3." << arr[2] << "  4." << arr[3] << "  5." << arr[4] << "  6." << arr[5] << "  7." << arr[6] << "  8." << arr[7] << "  9." << arr[8] << "  10." << arr[9] << endl;
            }
            else if (a=="up") // Go to foyer
            {
                cout << "\n You're in the foyer. You can go: North, up, down, or south." << endl;
                area=2;
            }
            else if (a=="shrink") // WIN
            {
                cout << "\n\n\n CONGRADULATIONS!!! \n\n\n YOU WIN!!!!!!!" << endl;
                cout << "\n\n\n\n\n\n\n\n You're still in the basement though! \n\n Try to find the secret area!" << endl;
            }
            else if (a=="add") // NO MORE NOTES
            {
                cout << "\n Sorry, no more notes!" << endl;
            }
            else
            {
                cout << " " << endl;
            }
        }
    }
}

Last edited by johndo77 (2010-10-03 21:15:22)


Crizapples

Offline

 

#2 2010-10-03 21:17:19

jackrulez
Scratcher
Registered: 2009-08-01
Posts: 1000+

Re: C++ Code

Wow.


Yawn, another boring text signature. I should really make something better.

Offline

 

#3 2010-10-03 21:20:12

ThePCKid
Scratcher
Registered: 2009-09-16
Posts: 1000+

Re: C++ Code

I'm compiling a .EXE file  big_smile

Offline

 

#4 2010-10-03 21:39:16

johndo77
Scratcher
Registered: 2010-07-30
Posts: 1000+

Re: C++ Code

ThePCKid wrote:

I'm compiling a .EXE file  big_smile

I bet it's still compiling.


Crizapples

Offline

 

#5 2010-10-03 21:42:37

ThePCKid
Scratcher
Registered: 2009-09-16
Posts: 1000+

Re: C++ Code

johndo77 wrote:

ThePCKid wrote:

I'm compiling a .EXE file  big_smile

I bet it's still compiling.

No  tongue

Offline

 

#6 2010-10-04 05:00:12

iCode-747
Scratcher
Registered: 2009-11-21
Posts: 1000+

Re: C++ Code

Very nice.

I can't read C++, but whatever.


-End Transmission-

Offline

 

#7 2010-10-04 17:36:45

johndo77
Scratcher
Registered: 2010-07-30
Posts: 1000+

Re: C++ Code

iCode-747 wrote:

Very nice.

I can't read C++, but whatever.

Well, you can download C++ and play the game if you want to.


Crizapples

Offline

 

Board footer