speedingbullet
January 7th, 2008, 02:22 AM
int main()
{
int attack;
int hp = 7;
while (hp > 0 && --hp)
{
cout <<"ATTACK!\n";
cout <<"but what do you choose?\n";
cin >> attack;
cout << "your opponent still has " << hp <<" hp\n";
}
return 0;
}
I am trying to design a simple combat system so I'll know how to make one... but I can't seem to get it right. No matter what I enter in the program, the program for some reason thinks its always a 1:
ATTACK!
but what do you choose?
1
your opponent still has 6 hp
ATTACK!
but what do you choose?
2
your opponent still has 5 hp
ATTACK!
but what do you choose?
3
your opponent still has 4 hp
ATTACK!
but what do you choose?
4
your opponent still has 3 hp
ATTACK!
but what do you choose?
5
your opponent still has 2 hp
ATTACK!
but what do you choose?
the strange thing is, It was working earlier, but then when I started adding on to it, it didn't work anymore, so I undid a lot of changes until it was in its original form which you see now, but It still didn't work anymore... what on earth am I doing wrong?
{
int attack;
int hp = 7;
while (hp > 0 && --hp)
{
cout <<"ATTACK!\n";
cout <<"but what do you choose?\n";
cin >> attack;
cout << "your opponent still has " << hp <<" hp\n";
}
return 0;
}
I am trying to design a simple combat system so I'll know how to make one... but I can't seem to get it right. No matter what I enter in the program, the program for some reason thinks its always a 1:
ATTACK!
but what do you choose?
1
your opponent still has 6 hp
ATTACK!
but what do you choose?
2
your opponent still has 5 hp
ATTACK!
but what do you choose?
3
your opponent still has 4 hp
ATTACK!
but what do you choose?
4
your opponent still has 3 hp
ATTACK!
but what do you choose?
5
your opponent still has 2 hp
ATTACK!
but what do you choose?
the strange thing is, It was working earlier, but then when I started adding on to it, it didn't work anymore, so I undid a lot of changes until it was in its original form which you see now, but It still didn't work anymore... what on earth am I doing wrong?