View Full Version: Save The Princess!

C++ Game Dev > C++ Game Creations > Save The Princess!


Title: Save The Princess!


Kaz - December 30, 2005 12:26 AM (GMT)
Ok I was still bored so I made another adventure game. And dont read the code, it spoils the fun because the game is supposed ot be funny.
CODE
#include<iostream>
using namespace std;
main()
{cout<<"Save the Princess!\nBy Kaz\nE to exit\n";
cout<<"Oh no the Princess has been kidnapped! You must go save her!\n";
cout<<"Will you save the Princess?\nY for yes, N for no\n";
char key;
string event="choice";
bool end=false;
while (event!="nothing")
{
cin>>key;
if (key=='e' || key=='E')
{exit(1);}
if (event=="choice")
{
if (key=='y' || key=='Y')
{cout<<"You leave the castle\n";event="river";
cout<<"You find yourself at a river. Will you try to jump it or make a raft?\nJ for jump, R for raft\n";}
if (key=='n' || key=='N')
{cout<<"You get tortured for not saving the Princess. You live the rest of your life in a dungeon.\n";system("pause");exit(1);}
}
if (event=="river")
{if (key=='j' || key=='J')
{cout<<"You try to jump it but fall into the river and drown. Game Over.\n";system("pause");exit(1);}
if (key=='r' || key=='R')
{cout<<"You make a raft and row across the river. You make it safely to the other side.\n";event="town";
cout<<"After a days walk you arrive at a town. Will you make sure you are going the    right way by asking a villager?\nY for yes, N for no\n";}
}
if (event=="town")
{if (key=='y' || key=='Y')
{cout<<"The villager tells you which way to go. After resting for a few hours you head  back on your journey. After some more walking you stop at a fork in the road.   Which way will you go?\nL for left, R for right\n";event="path";}
if (key=='n' || key=='N')
{cout<<"You thank the villager and start walking. It seems you went the wrong way and   fall off a cliff. Game Over.\n";system("pause");exit(1);}
}
if (event=="path")
{if (key=='l' || key=='L')
{cout<<"You walk along the road and find a hamster, he then eats you. Noob. Game Over.\n";system("pause");exit(1);}
if (key=='r' || key=='R')
{cout<<"You finally make it to the castle where the Princess is.";
cout<<"Will you attack the     guards or climb up the vines?\nA for attack, C for climb\n";event="castle";}
}
if (event=="castle")
{if (key=='a' || key=='A')
{cout<<"You use your kung fu skills and totally own the guards. You find the Princess   and go home.\n";event="marriage";
cout<<"The Princess wants to marry you. Will you accept?\nY for yes, N for no\n";}
if (key=='c' || key=='C')
{cout<<"You climb up the vines but they break and you fall and break your neck.\nGame Over.\n";system("pause");exit(1);}
}
if (event=="marriage")
{if (key=='y' || key=='Y')
{cout<<"You get married and are unhappy the rest fo your life because you get nagged to  death. Game Over.\n";system("pause");exit(1);}
if (key=='n')
{cout<<"You blow the Princess off and go to the brothel/hostel. The End\n";end=true;}
}
if (end==true)
{cout<<"Coded by Kaz\nStory by Kaz\nMusic by Kaz\nGraphics by Kaz\n";system("pause");exit(1);}
}
}


Hope you like it! :D

gamehawk - December 30, 2005 12:50 AM (GMT)
You might want to tell them they have to type it in lowercase or use or. Like this
CODE

if (key=='e' || key=='E')
{
//do code
}


Edit 1:
It's funny, I love CYOA's (Choose Your Own Adventues). Not to copy, but I think I might make one of these!
---
Edit 2:
Darn I married her and I got nagged! Okay now I won! P.S. Great music and graphics! :P

Kaz - December 30, 2005 01:50 AM (GMT)
Ok edited orginal code.

Glad you like it, and go ahead make your own. I made a game like yours.

Yea the gfx and music is awesome! :P

gamehawk - December 30, 2005 02:04 AM (GMT)
Good first game, or second w/e. Everyone here should try it out!

Kaz - December 30, 2005 02:10 AM (GMT)
Yay, now I just dont know what to do to test myself :(

gml_josea - December 30, 2005 03:30 AM (GMT)
lol, was kinda funny, specially the part of mariage.
About the credit, did I hear any souneds there :P?

Kaz - December 30, 2005 04:07 AM (GMT)
If you have imaginary speakers then yes :D

gml_josea - December 30, 2005 02:46 PM (GMT)
:lol:

BGamed - December 30, 2005 05:52 PM (GMT)
im new to c++, but how do I play it, or activate the code? :huh:

soten355 - December 30, 2005 06:00 PM (GMT)
basically, you'll need a compiler. I use Dev C++, you can find it just by typing Dev C++ in google.
The next step would be to copy the code he posted and paste it into a new file on Dev C++. Then compile it and run it(you should be able to find the button in Dev C++). That's how it works, and it's cool.

LauriP - December 30, 2005 06:11 PM (GMT)
Its nice, a little bit hard but thats how those games work :rolleyes:

Daniel - January 19, 2006 07:47 AM (GMT)
Good Game :P

Kaz - January 19, 2006 09:31 PM (GMT)
Thank you :)

Ludamad - January 22, 2006 02:35 PM (GMT)
A classic :P




* Hosted for free by InvisionFree