need some help in C++ :P
-
30 มีนาคม 2555 5:58
k so as a beginner i was thinking id do something simple; a text adventure came to mind :/
so after each death, i need the cmd to pause so the participant can read it. heres what i got
as you can see most is just copy past work :P
// Adventure_Game.cpp : Defines the entry point for the console application.
//#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
int Choice;
printf( "Welcome to the coolest adventure game ever!!!\n\n");
printf( "In this adventure game we will experiance a number of situations.\n");
printf( "Each situation follows the same pattern for right now\n");
printf( "1. A situation will be presented.\n");
printf( "2. You will be given some choices.\n");
printf( "3. You will be asked to make a choice.\n");
printf( "4. The result of your choice will be shown.\n");
printf( "5. Be warned as you progress more odds will be stacked against you incresing the death ratio.\n");
printf( "\n\nYou are walking down a dusty road.\n");
printf( "You see a gemstone in the middle of the road.\n");
printf( "It is bright and shiny.\n");printf( "\n\nHere are your choices:\n");
printf( "1. Pick the gemstone up.\n");
printf( "2. Kick the gemstone off the road.\n");
printf( "3. Stomp on the gemstone.\n");printf( "Your choice?");
scanf( "%d", &Choice);if( Choice == 1)
{
printf("\n\nYou pick up the gemstone and put it in your backpack.\n");
printf("It becomes an incendiary ball of flame.\n");
printf("You drop to the ground and roll of the side of the road.\n");
printf("Your backpack is now a shoulder pile of ash.\n");
printf("You notice the entrance to a cave.\n");}
else if(Choice == 2)
{
printf("\n\nThe gemstone scoots off the road.\n");
printf("You foolw the gemstone off the road to see where it went.\n");
printf("You notice the entrance to a cave.\n");
}
else if(Choice == 3)
{
printf("\n\nThe gemstone blows you sky high.\n");
printf("You hope you health insurance premiums are up to date.\n");
printf("You land off the side of the road.\n");
printf("You notice the entrance to a cave.\n");
}
else if(Choice == 4)
{
printf("\n\nThat was not a choice you bozo.\n");
printf("You are now dead.\n");
return 0;
}printf("\n\nThe entrance of the cave is inviting.\n");
printf("You are tempted to enter and explore.\n");
printf("It looks kind of dark.\n");printf("\n\nHere are your choices:\n");
printf("1. Run away.\n");
printf("2. Take a nap.\n");
printf("3. Carefully enter the cave.\n");
printf( "Your choice?");
scanf( "%d", &Choice);if( Choice == 1)
{
printf("\n\nAs you start to run, you are caught by a trap.\n");
printf("The trap was hidden in the grass by some natives.\n");
printf("You are catapulted into the cave.\n");
}
else if(Choice == 2)
{
printf("\n\nAs you dream you have the feeling of being carried somewhere.\n");
printf("Shortly after you find yourself awake in a dark room with no way out.\n");
printf("After three days of receiving no food or water it obvious they are not trying to keep you alive and you slowly die.\n");
printf("\n\nGame Over!!!!\n");
return 0;}
else if(Choice == 3)
{
printf("\n\nAs you slowly step into the darkness you trip on something.\n");
printf("You blindly search around your feet, till you feel the hilt of a sword.\n");
printf("You carefully slide the sword in-between your belt.\n");
printf("You spot a dimly lit room up ahead and slowly walk twords the light.\n");
}printf("\n\nAs you enter the cave you see a lit room, you soon find what was causing the glow.\n");
printf("As you see the giant glowing mushrooms you are awestruck, you quick start cutting and pocketing them.\n");
printf("As you start walking out of the cave back home to sell you new found goods, a rare majestic unicorn appears and he looks angry.\n");printf("\n\nHere are your choices:\n");
printf("1. Stand your ground and draw you sword of single combat, while unlessing your loudest war cry!!!\n");
printf("2. Drop everything you have found and slowly approach the unicorn.\n");
printf("3. Throw random things at the unicorn and run for it.\n");
printf( "Your choice?");
scanf( "%d", &Choice);if( Choice == 1)
{
printf("\n\nAs the beast as you race toward the middle of the cave you warrior mentality comes into play.\n");
printf("After a mild struggle the beats stops putting up a fight and goes silent.\n");
printf("You leave the cave heading home to boast of you exploration with all your goods and new unicorn horn in hand as a trophy.\n");
return 0;
}
else if(Choice == 2)
{
printf("\n\nYou drop everything you have and slowly walk forward.\n");
printf("The beast is in good manner, however you steped on a trap while walking.\n");
printf("As darts shoot out of the walls the world slows down and you relize this is how you will die, so close yet so far.\n");
printf("Game Over!!!!\n");
return 0;
}
else if(Choice == 3)
{
printf("\n\nYou run as quickly as you can throwing objects from you pockets or off the ground.\n");
printf("The unicorn quickly closes the distance between you and you trip while looking back at it.\n");
printf("As you turn around the last image you see is the size of the unicorn's hoof.\n");
printf("Game Over, hows it feel to be killed by a horse?\n");
}
return 0;
}
ตอบทั้งหมด
-
30 มีนาคม 2555 7:55
#include "stdafx.h"
#include <stdlib.h>
void myexit(void)
{
puts("Press Enter key to end ...");
getc(stdin);
}
int _tmain(int argc, _TCHAR* argv[])
{
int Choice;
atexit(myexit);
...
- Wayne- เสนอเป็นคำตอบโดย Helen ZhaoModerator 3 เมษายน 2555 6:32
- ทำเครื่องหมายเป็นคำตอบโดย Helen ZhaoModerator 9 เมษายน 2555 2:07
-
30 มีนาคม 2555 22:38