This skin was created by Rocky of the IF Skin Zone

Fully Featured & Customizable Free Forums
InvisionFree - Free Forum Hosting
Welcome to C++ Game Dev. We hope you enjoy your visit.


You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Name:   Password:


Pages: (2) [1] 2  ( Go to first unread post )

 Escape The Cave!, Inspired by Kaz's Classic
Ludamad
Posted: Jan 22 2006, 05:29 PM


Mega Member


Group: Members
Posts: 97
Member No.: 47
Joined: 17-January 06



laugh.gif ESCAPE THE CAVE! laugh.gif

Press X to quit.
Dying restarts the game, losing all items you got.
If you really want the answer to the riddle PM me or look at the code.




CODE
#include <cstdlib>
#include <iostream>
using namespace std;
/* the global vars */
bool key;
bool knowpass;
string event;
char pick;
bool monsterone;
bool food;
bool treasure;
bool knowdennis;
/**/

int init_vars(void)
{
food=0;
key=0;
knowpass=0;
event="start";
monsterone=0;
treasure=0;
knowdennis=0;
}


int main(void)
{
init_vars();
cout << "Type x or X at any time to quit.\n";

/*keep going until the game sends the signal to end*/
while (event != "end")
{
/* The events are things that can happen, idea from Save the princess*/


if (event=="start")
{
   cout << "     \nYou find yourself lost in a smelly cave.\nYou are brandishing a shiny sword for some reason and feel the urge to hold it \naloft. Well... now what?  ";
   cout << "\n\n\nA: Stab yourself\nB: Walk into a wall\nC: Put a cloth over your face\nD: Walk forwards. \n";
   cin >> pick;
       if (pick == 'X' || pick == 'x')
   {
            cout << "\nQuitter! \n";
            system("PAUSE");
            exit(1);
   }
   if (pick == 'A' || pick == 'a')
   {
            cout << "\nYou die! What did you think was going to happen? \n";
            init_vars();
   }
   if (pick == 'B' || pick == 'b')
   {
            cout << "\nWell... that was pointless \n";
   }            
       if (pick == 'C' || pick == 'c')
   {
            cout << "\nThe stench bothers you less \n";
            event="nosmell";
   }  
       if (pick == 'D' || pick == 'd')
   {
            cout << "\nYou leave and the overwhelming putrid smell kills you \n";
            init_vars();
   }
           if (pick == 'K' || pick == 'k')
   {          if (knowpass==0)
              {
                 cout << "\nYou find a small man that you didn't notice before, he asks for a password,\nunfortunately you guess wrong \n";
              }
              else
              {
                 cout << "\nYou find the small man, he asks you for a password, you give him it.\n He gives you a key.";
              key=1;
                 }
            event = "start";
   }      
}


if (event=="nosmell")
{
   cout << "     \nYou are brandishing a shiny sword for some reason and feel the urge to hold it \naloft. Well... now what?  ";
   cout << "\n\n\nA: Stab yourself\nB: Walk into a wall\nC: Walk forwards\nD: Take off cloth\n";
   cin >> pick;
       if (pick == 'X' || pick == 'x')
   {
            cout << "\nQuitter! \n";
            system("PAUSE");
            exit(1);
   }
   if (pick == 'A' || pick == 'a')
   {
            cout << "\nYou die! What did you think was going to happen?\n";
            init_vars();
   }
   if (pick == 'B' || pick == 'b')
   {
            cout << "\nWell... that was pointless \n";
   }            
       if (pick == 'C' || pick == 'c')
   {
            cout << "\nYou continue onward\n";
            event="farther";
   }  
           if (pick == 'D' || pick == 'd')
   {
            cout << "\nYou take it off\n";
            event="start";
   }  
              if (pick == 'K' || pick == 'k')
   {          if (knowpass==0)
              {
                 cout << "\nYou find a small man that you didn't notice before, he asks for a password,\nunfortunately you guess wrong \n";
                           event = "nosmell";
              }
              else
              {
                 cout << "\nYou find the small man, he asks you for a password, you give him it.\n He gives you the key of doom.";
                           event = "nosmell";
              key=1;
                 }
            event = "nosmell";
   }      
}


if (event=="farther")
{
   cout << "\n        There are three paths you can travel on.\n And you can go back if you really want.";
   cout << "\n\n\nA: Go to the leftmost path\nB: Go to the middle path\nC: Go to the rightmost path\nD: Walk backwards. \n";
   cin >> pick;
       if (pick == 'X' || pick == 'x')
   {
            cout << "\nQuitter! \n";
            system("PAUSE");
            exit(1);
   }
   if (pick == 'A' || pick == 'a')
   {
            cout << "\nYou travel on the leftmost path. \n";
            if (monsterone==0)
            {
            event = "leftpathwithmonster";
            }
            else
            {
            event="leftpath";
            }
   }
   if (pick == 'B' || pick == 'b')
   {
            cout << "\nYou travel on the middle path. \n";
            event="middlepath";
   }            
       if (pick == 'C' || pick == 'c')
   {
            cout << "\nYou travel on the rightmost path \n";
            event="rightpath";
   }  
       if (pick == 'D' || pick == 'd')
   {
            cout << "\nYou walk backwards to the where you were before.\n";
            event = "nosmell";
   }  
}

if (event=="leftpathwithmonster")
{
   cout << "\n        You travel along the left path and encounter a monster. \n The monster is big.";
   cout << "\n\n\nA: Stab it!\nB: Ask the monster to leave\nC: Go back\nD: Walk onwards \n";
   cin >> pick;
       if (pick == 'X' || pick == 'x')
   {
            cout << "\nQuitter! \n";
            system("PAUSE");
            exit(1);
   }
   if (pick == 'A' || pick == 'a')
   {
            cout << "\nYou stab the monster, the monster barely notices \n";
            event = "leftpathwithmonster";
   }
   if (pick == 'B' || pick == 'b')
   {
            cout << "\nThe monster leaves\n";
            monsterone=1;
            event="leftpath";
   }            
       if (pick == 'C' || pick == 'c')
   {
            cout << "\nYou go back \n";
            event="farther";
   }  
       if (pick == 'D' || pick == 'd')
   {
            cout << "\nYou are stopped in your attempt to go further by the monster.\n";
            event = "leftpathwithmonster";
   }  
}
 

if (event=="leftpath")
{
   cout << "\n        You are on the left path.";
   cout << "\n\n\nA: Stab yourself\nB: Dance \nC: Go back\nD: Walk onwards \n";
   cin >> pick;
       if (pick == 'X' || pick == 'x')
   {
            cout << "\nQuitter! \n";
            system("PAUSE");
            exit(1);
   }
   if (pick == 'A' || pick == 'a')
   {
            cout << "\nYou die. Yay. \n";
            init_vars();
   }
   if (pick == 'B' || pick == 'b')
   {
            cout << "\nYou dance until you feel awkward. \n";
            monsterone=1;
            event="leftpath";
   }            
       if (pick == 'C' || pick == 'c')
   {
            cout << "\nYou go back \n";
            event="farther";
   }  
       if (pick == 'D' || pick == 'd')
   {
            cout << "\nYou continue left.\n";
            event = "leftpathfarther";
   }  
}
if (event=="leftpathfarther")
{
   cout << "\n        You find a treasure chest, glowing with a rich creamy glow. \n You can't get any farther left than this. There is food on the floor.";
   cout << "\n\n\nA: Go back\nB: Open it \nC: Take food \nD: Dance \n";
   cin >> pick;
       if (pick == 'X' || pick == 'x')
   {
            cout << "\nQuitter! \n";
            system("PAUSE");
            exit(1);
   }
   if (pick == 'A' || pick == 'a')
   {
            cout << "\nYou go back. \n";
            event="leftpath";
   }
   if (pick == 'B' || pick == 'b')
   {        if (key==0)
            {cout << "\nYou try to open it with your bare hands, unfortunately it's locked. \n";}
            else
            {
            cout << "\nYou place the key inside and open it. \n";
            if (treasure==0)
            {cout << "\nYou get the treasure. \n";}
            else
            {cout << "\nIt's already empty... \n";}    
            treasure=1;
            }          
         
            event="leftpathfarther";
   }            
       if (pick == 'C' || pick == 'c')
   {        if (food==0)
   {
            cout << "\nYou take the food.\n";
            }
            else
                {
            cout << "\nYou already took the food.\n";
            }
            food=1;
            event="leftpathfarther";
   }  
       if (pick == 'D' || pick == 'd')
   {
            cout << "\nYou dance. Yay.\n";
            event = "leftpathfarther";
   }  
}

if (event=="middlepath")
{
   cout << "     \n You find a talking gerbil, he eyes you. You wonder how you know it can talk.";
   cout << "\n\n\nA: Talk to the gerbil\nB: Play with the gerbil\nC: Go backwards\nD: Walk forwards. \n";
   cin >> pick;
       if (pick == 'X' || pick == 'x')
   {
            cout << "\nQuitter! \n";
            system("PAUSE");
            exit(1);
   }
   if (pick == 'A' || pick == 'a')
   {
            cout << "\nThe gerbil tells you that it is very bored.\n";
            event="middlepath";
   }
   if (pick == 'B' || pick == 'b')
   {
            cout << "\nThe gerbil giggles, he then tells you that the man ahead is named Dennis. \n";
         knowdennis=1;
         event="middlepath";}  
       if (pick == 'C' || pick == 'c')
   {
            cout << "\nYou go backwards \n";
            event="farther";
   }  
       if (pick == 'D' || pick == 'd')
   {
            cout << "\nYou leave.\n";
            event="middlefarther";
   }

}
if (event=="middlefarther")
{
   cout << "     \n You see a man pacing back and forth in deep thought. \nYou can't go any further on the middle path.";
   cout << "\n\n\nA: Talk to the man\nB: Punch a wall\nC: Walk backwards\nD: Spin around\n";
   cin >> pick;
       if (pick == 'X' || pick == 'x')
   {
            cout << "\nQuitter! \n";
            system("PAUSE");
            exit(1);
   }
   if (pick == 'A' || pick == 'a')
   {
            if (knowdennis ==0)
            {cout << "\nYou can't seem to get the man's attention.\n";}
            else
            {
               cout<<"\nYou call the man's name and he looks at you,\n he then says he'll let you in on a secret for food.\n";
            if (food ==0)
            {
                     cout << "\n You don't have any food.\n";}
                     else
                     {
                         cout << "\n You give him food you found,\n he tells you about a key in the entrance of the cave.\n He tells you the password you need to get it is Boing.\n He also says something about typing K.\n";
                         knowpass=1;
                         }      
                         }              
            event="middlefarther";
   }
   if (pick == 'B' || pick == 'b')
   {
            cout << "\nOww. \n";
         event="middlefarther";}  
       if (pick == 'C' || pick == 'c')
   {
            cout << "\nYou go backwards \n";
            event="middlepath";
   }  
       if (pick == 'D' || pick == 'd')
   {
            cout << "\nWHEEEEEEEE!.\n";
            event="middlefarther";
   }

}
if (event=="rightpath")
{
   cout << "     \nYou see a giant gate with a guard.\n He says in order to get through you need to pay.";
   cout << "\n\n\nA: Talk to the guard\nB: Sing a song\nC: Walk backwards\nD: Ask to go through gate\n";
   cin >> pick;
       if (pick == 'X' || pick == 'x')
   {
            cout << "\nQuitter! \n";
            system("PAUSE");
            exit(1);
   }
   if (pick == 'A' || pick == 'a')
   {
            cout << "\nThe guard chats with you about politics.\n";              
            event="rightpath";
   }
   if (pick == 'B' || pick == 'b')
   {
            cout << "\nThe guard compliments you on your voice. \n";
         event="rightpath";}  
       if (pick == 'C' || pick == 'c')
   {
            cout << "\nYou go backwards \n";
            event="farther";
   }  
       if (pick == 'D' || pick == 'd')
   {
            cout << "\nThe guard says he's tired of\n guarding the gate and will let you through for money.\n";
            if (treasure==1)
            {
                          cout << "\n You give the guard your treasure and he let's you through. \n He says once you go through you can't go back. \n He decides to travel alongside you.";
            event="superpath";
            }
            else
            {event="rightpath";}
   }

}


if (event=="superpath")
{
   cout << "     \nYou are on the otherside of the gate. The guard says an exit is not far off.";
   cout << "\n\n\nA: Stab yourself\nB: Go forward\nC: Dance!!\nD: Go back \n";
   cin >> pick;
       if (pick == 'X' || pick == 'x')
   {
            cout << "\nQuitter! \n";
            system("PAUSE");
            exit(1);
   }
   if (pick == 'A' || pick == 'a')
   {
            cout << "\nYou die! What did you think was going to happen? \n";
            init_vars();
   }
   if (pick == 'B' || pick == 'b')
   {
            cout << "\nYou continue on your journey.\n";
            event="computerplace";
   }            
       if (pick == 'C' || pick == 'c')
   {
            cout << "\nYou feel cool.\n";
            event="superpath";
   }  
       if (pick == 'D' || pick == 'd')
   {
            cout << "\nYou can't.";
            event="superpath";
   }    
}
if (event=="computerplace")
{
   cout << "     \nYou find yourself in a high tech room.\n There is a riddle on the screen of a computer.\n It reads: Two of these doors lead to doom, the other to safety.\n The clue is that two of the doors have a lie written on them,\n the other the truth.";
   cout << "\n\n\nA: Enter door A which says: Door B has a lie on it\nB: Enter door B which says A is lying and C is the right door\nC: Enter door C which says door B is not the correct door and that A is telling the truth.\nD: Leave\n";
   cin >> pick;
       if (pick == 'X' || pick == 'x')
   {
            cout << "\nQuitter! \n";
            system("PAUSE");
            exit(1);
   }
   if (pick == 'A' || pick == 'a')
   {
            cout << "\nYou die! You picked the wrong door and get spammed by noobs to death!\n";
            init_vars();
   }
   if (pick == 'B' || pick == 'b')
   {
            cout << "\nYou die! You picked the wrong door and get eaten by Alpha_Man! \n";
            init_vars();
   }            
       if (pick == 'C' || pick == 'c')
   {
            cout << "\nYou die... just kidding you enter the correct door!\n";
            event="superpathplus";
   }  
       if (pick == 'D' || pick == 'd')
   {
            cout << "\nOK.";
            event="superpath";
   }    
}
if (event=="superpathplus")
{
   cout << "     \nYou find yourself outside. You find a monster here. ";
   cout << "\n\n\nA: Stab it!!\nB: Wait\nC: Think about life\nD: Kick the monster\n";
   cin >> pick;
       if (pick == 'X' || pick == 'x')
   {
            cout << "\nQuitter! \n";
            system("PAUSE");
            exit(1);
   }
   if (pick == 'A' || pick == 'a')
   {
            cout << "\nYou stab the monster! You are finally free and safe! YOU WIN!!";
            cout << "\nCoding by Ludamad \n Inspired by 'Save the princess' by Kaz \n Special thanks to Gamehawk and Alpha Man\n";
            system("PAUSE");
            exit(1);
   }
   if (pick == 'B' || pick == 'b')
   {
            cout << "\nYou wait... \n";
            event="superpathplus";
   }            
       if (pick == 'C' || pick == 'c')
   {
            cout << "\nYou wonder what happens when you die, the monster feels neglected.\n";
            event="superpathplus";
   }  
       if (pick == 'D' || pick == 'd')
   {
            cout << "\n You kick the monster. The monster runs away, and you feel happy. \n The guard says goodbye and leaves. \n You go to your house and go onto 64digits.com. \n You read about GML_Josea's crappy life. YOU WIN!!";
                         cout << "\n Coding by Ludamad \n Inspired by 'Save the princess' by Kaz \n Special thanks to Gamehawk, Alpha Man, GML_Josea and FirestormX\n Have a good day!\n";
            system("PAUSE");
            exit(1);
   }    
}

}

system("PAUSE");
   return 0;
}

Top
Neken
Posted: Jan 22 2006, 05:43 PM


DirectX Guru


Group: Global Moderators
Posts: 515
Member No.: 11
Joined: 24-September 05



tip :

tolower(char achar) returns the lower ascii character ... so :

CODE

if ( achar == 'A' || achar == 'a')

//could be done like that :

if ( tolower(achar) == 'a')

//or ... simplier :

cin >> achar;
achar = tolower(achar);

if( achar == 'a')


--------------------
Top
gamehawk
Posted: Jan 22 2006, 06:08 PM


Master Member


Group: Admin
Posts: 1,363
Member No.: 15
Joined: 11-December 05



Funny!


--------------------
user posted image
-----
Last Updated: October 23, 2006
Top
Stenny
Posted: Jan 22 2006, 06:23 PM


C++ Composer


Group: Members
Posts: 475
Member No.: 49
Joined: 17-January 06



It was funny indeed! Especially the stab yourself and walk into a wall tongue.gif


--------------------
user posted image

BLOOP!
Top
soten355
Posted: Jan 22 2006, 06:25 PM


Teh Adminoxorz


Group: Admin
Posts: 339
Member No.: 1
Joined: 21-March 05



Twas funny. Nice work!


--------------------
user posted image
R.I.P. Shawn Noel
Darkness Falls
Top
Ludamad
Posted: Jan 22 2006, 07:46 PM


Mega Member


Group: Members
Posts: 97
Member No.: 47
Joined: 17-January 06



Thanks guys, I was looking at tolower but something didn't work and I took the easier albeit a bit longer route anyway thanks tongue.gif
Top
Kaz
Posted: Jan 23 2006, 09:39 PM


Grand Champian Member


Group: Members
Posts: 223
Member No.: 17
Joined: 11-December 05



Lol that was awesome. And yay my game is a classic!


--------------------
Top
Ludamad
Posted: Jan 23 2006, 10:29 PM


Mega Member


Group: Members
Posts: 97
Member No.: 47
Joined: 17-January 06



Thanks man
Top
gml_josea
Posted: Jan 24 2006, 12:57 AM


I'm a google bot


Group: Global Moderators
Posts: 710
Member No.: 18
Joined: 12-December 05



hehe, you got a nice game. when I got stuck at the riddle I just took a look at the source code =P


--------------------
gml_josea Signature V. 4.3

And always remember, gml_josea is always written in lowercase, from beginning to end.
Top
Ludamad
Posted: Jan 24 2006, 01:03 AM


Mega Member


Group: Members
Posts: 97
Member No.: 47
Joined: 17-January 06



Hmm this is the steps to solve it:



SPOLIERS




















-Realize door C cant tell the truth because it is saying that something else is saying the truth, in order for it to be true two doors would have to be true
-See that if door C lies then the door it says is telling the truth is also lying.
-By process of elimination door b is true
-door b states door c is the right door
therefore door c is right
Top
gamehawk
Posted: Jan 24 2006, 01:14 AM


Master Member


Group: Admin
Posts: 1,363
Member No.: 15
Joined: 11-December 05



I had thought it out and still couldn't get it. Never looked at source, and finally won by process of elimination! Whooo!


--------------------
user posted image
-----
Last Updated: October 23, 2006
Top
gml_josea
Posted: Jan 24 2006, 01:18 AM


I'm a google bot


Group: Global Moderators
Posts: 710
Member No.: 18
Joined: 12-December 05



wow. Ludamad, if you really made yourself that riddle I may ask your help when I make my GM RPG smile.gif


--------------------
gml_josea Signature V. 4.3

And always remember, gml_josea is always written in lowercase, from beginning to end.
Top
Ludamad
Posted: Jan 24 2006, 01:29 AM


Mega Member


Group: Members
Posts: 97
Member No.: 47
Joined: 17-January 06



Ah, gamehawk how many times did you play it through? xD
GML_Josea, yeah I made it. I thought it was simple... I guess not. Sure I'd like to help.
Top
gamehawk
Posted: Jan 24 2006, 01:51 AM


Master Member


Group: Admin
Posts: 1,363
Member No.: 15
Joined: 11-December 05



There are lots of riddles like that, or so I've seen. With that exact thing. Except they flipped it around a little tongue.gif.


--------------------
user posted image
-----
Last Updated: October 23, 2006
Top
Ludamad
Posted: Jan 24 2006, 01:59 AM


Mega Member


Group: Members
Posts: 97
Member No.: 47
Joined: 17-January 06



lol, well I still made it ;P
Top
InvisionFree - Free Forum Hosting
Join the millions that use us for their forum communities. Create your own forum today.

Topic OptionsPages: (2) [1] 2 



Hosted for free by InvisionFree* (Terms of Use: Updated 2/10/2010) | Powered by Invision Power Board v1.3 Final © 2003 IPS, Inc.
Page creation time: 0.1475 seconds | Archive