I'm trying to put a delay in this text game im making delay(1000);
but it dont work need an identifier and i cant find it... if you can plz email me at [email protected] or icq me at 97034780.
I'm trying to put a delay in this text game im making delay(1000);
but it dont work need an identifier and i cant find it... if you can plz email me at [email protected] or icq me at 97034780.
Include windows.h and use Sleep() instead.
And there must be a big S when using it.
nothing inside the ()?? ok thx
its just a dumb text game but can you tell me whats wrong (aint very far yet).
#include <iostream.h>
#include <windows.h>
void main(){
int number = 1;
cout << "You open your eyes to see a lady bent over you appling medication to your wound on your leg.\n";
cout << "You can ask:\n1 = Will I be alright?\n2 = Can I leave now?\n3 = What happened?\n";
cin >> number;
if (number == 1)
cout << "Will I be alright?\n\n";
if (number == 1)
cout << "Yes, you just need some rest.\n\n";
if (number == 2)
cout << "Can I leave now?\n\n";
if (number == 2)
cout << "You can, but it won't do you any good. The stiches will break.\n\n";
if (number == 3)
cout << "What happened?\n\n";
if (number == 3)
cout << "You were fighting some nasty orc's outside of town. They knocked you out and were going to eat you, but papa found you. I will take care of you until you can go back out on your own.\n";
cout << "You feel yourself drift off to sleep.\n\n";
Sleep(1000);
cout << "\n\nZzZzZzZz......\n";
Sleep(1000);
cout << "\n\nZzZzZzZzZzZzZzZz..\n";
cout << "\n\nBOOOOOOOOM!!!!\n";
cout << "You sit up quickly looking around. You spot your pants and scabbard on the chair next to your bed, and quickly get up and put them on.\nYou slip on your boots and run down the spiral staircase to see what the noise was.\nWhen you get out you look to the left and see a squad of orcs carrying your friends away.\nYou try to chase after them, but can't keep up.\nYou hear noises behind you.\n\nShould you:\n1 = Turn around towards the noise.\n2 = Keep trying to keep up with the orc's taking your friends.\n3 = Run away into a deep dark cave.\n";
cin >> number;
if (number == 1)
cout << "You turn around like lightning and draw your sword. A orc swings his mighty club at you but you dodge it. You jab but he was too quick, He swings it again but you move and stab him in the ribs.\n";
}
Yah its correct but, your coding style is pretty bad. Why do you have so many if statements for the SAME condition?Originally posted by Unregistered
its just a dumb text game but can you tell me whats wrong (aint very far yet).
#include <iostream.h>
#include <windows.h>
void main(){
int number = 1;
cout << "You open your eyes to see a lady bent over you appling medication to your wound on your leg.\n";
cout << "You can ask:\n1 = Will I be alright?\n2 = Can I leave now?\n3 = What happened?\n";
cin >> number;
if (number == 1)
cout << "Will I be alright?\n\n";
if (number == 1)
cout << "Yes, you just need some rest.\n\n";
if (number == 2)
cout << "Can I leave now?\n\n";
if (number == 2)
cout << "You can, but it won't do you any good. The stiches will break.\n\n";
if (number == 3)
cout << "What happened?\n\n";
if (number == 3)
cout << "You were fighting some nasty orc's outside of town. They knocked you out and were going to eat you, but papa found you. I will take care of you until you can go back out on your own.\n";
cout << "You feel yourself drift off to sleep.\n\n";
Sleep(1000);
cout << "\n\nZzZzZzZz......\n";
Sleep(1000);
cout << "\n\nZzZzZzZzZzZzZzZz..\n";
cout << "\n\nBOOOOOOOOM!!!!\n";
cout << "You sit up quickly looking around. You spot your pants and scabbard on the chair next to your bed, and quickly get up and put them on.\nYou slip on your boots and run down the spiral staircase to see what the noise was.\nWhen you get out you look to the left and see a squad of orcs carrying your friends away.\nYou try to chase after them, but can't keep up.\nYou hear noises behind you.\n\nShould you:\n1 = Turn around towards the noise.\n2 = Keep trying to keep up with the orc's taking your friends.\n3 = Run away into a deep dark cave.\n";
cin >> number;
if (number == 1)
cout << "You turn around like lightning and draw your sword. A orc swings his mighty club at you but you dodge it. You jab but he was too quick, He swings it again but you move and stab him in the ribs.\n";
}
Try looking up switch/case statements since it will help simplify your code. Good luck.
oh yeah ...if the reason why you are using so many if statements try this,
Code:if (number == 1) { cout << "Will I be alright?\n\n"; cout << "Yes, you just need some rest.\n\n"; }
Code:#include <iostream.h> #include <windows.h> int main(void) { int number = 1; cout << "You open your eyes to see a lady bent over you appling medication to your wound on your leg.\n"; cout << "You can ask:\n1 = Will I be alright?\n2 = Can I leave now?\n3 = What happened?\n"; cin >> number; switch(number) { case 1: cout << "Will I be alright?\n\n"; Sleep(1000); cout << "Yes, you just need some rest.\n\n"; break; case 2: cout << "Can I leave now?\n\n"; Sleep(1000); cout << "You can, but it won't do you any good. The stiches will break.\n\n"; break; case 3: cout << "What happened?\n\n"; Sleep(1000); cout << "You were fighting some nasty orc's outside of town.\nThey knocked you out and were going to eat you, \nbut papa found you. \nI will take care of you until you can go back out on your own.\n\n"; Sleep(2500); cout << "You feel yourself drift off to sleep.\n\n"; Sleep(1000); cout << "\n\nZzZzZzZz......\n"; Sleep(1000); cout << "\n\nZzZzZzZzZzZzZzZz..\n"; Sleep(500); cout << "\n\nBOOOOOOOOM!!!!\n"; Sleep(500); cout << "You sit up quickly looking around. You spot your pants and scabbard on the chair next to your bed, and quickly get up and put them on.\nYou slip on your boots and run down the spiral staircase to see what the noise was.\nWhen you get out you look to the left and see a squad of orcs carrying your friends away.\nYou try to chase after them, but can't keep up.\nYou hear noises behind you.\n\nShould you:\n1 = Turn around towards the noise.\n2 = Keep trying to keep up with the orc's taking your friends.\n3 = Run away into a deep dark cave.\n"; cin >> number; if (number == 1) { cout << "You turn around like lightning and draw your sword. A orc swings his mighty club at you but you dodge it. You jab but he was too quick, He swings it again but you move and stab him in the ribs.\n"; } }
EDIT:: void main() is evil!
Last edited by ErionD; 03-30-2002 at 01:48 PM.