Feb 8, 2013 at 3:12pm
I dont get whats happening...
I have put all this in resource.h.
What is wrong with my code?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
#include <iostream.h>
#include <stdlib.h>
#include <stdio.h>
int hp = 20, mp = 20, ehp = 35, move;
void lose (void)
{
cout << "You lose." << endl;
hp = 20;
mp = 20;
ehp = 20;
}
void win (void)
{
cout << "You win." << endl;
hp = 20;
mp = 20;
ehp = 20;
}
int main()
{
label:
cout << "ehp: " << ehp << endl << "hp: " << hp << endl << "mp: " << mp << endl << "(1) Attack" << endl << "(2) Magic Missle" <<endl << "(3) Summon" << endl;
cin >> move;
system("cls");
cout << "Status:" << endl;
if (move == 1)
{
cout << "You sliced the enemy with your sword." << endl;
ehp -= 1;
if (ehp < 0)
{
win();
return 0;
}
if (hp < 0)
{
lose();
return 0;
}
cout << "The enemy cast a Magic Missle." << endl << endl;
hp -= 2;
}
if (move == 2)
{
cout << "You cast a devistating Magic Missle." << endl;
ehp -= 2;
mp -= 1;
if (ehp < 0)
{
win();
return 0;
}
if (hp < 0)
{
lose();
return 0;
}
cout << "The enemy used his sword." << endl << endl;
hp -= 1;
}
if (move == 3)
{
cout << "You summoned Ultima!" << endl;
ehp -= 10;
mp -= 15;
hp -= 1;
if (ehp < 0)
{
win();
return 0;
}
if (hp < 0)
{
lose();
return 0;
}
cout << "The enemy used his sword." << endl << endl;
hp -= 1;
}
goto label;
}
|
Does it have to be console app or something?
Last edited on Feb 8, 2013 at 3:29pm
Feb 8, 2013 at 3:18pm
It should be <iostream> without .h.
Feb 8, 2013 at 3:21pm
Thanks, but now the game doesnt work properly...
Last edited on Feb 8, 2013 at 3:23pm