Or, if you'd like to keep in consistent with the code for player 1's attack, you could simply put it outside of the switch statement but inside the while loop (like line 57 or 58 in Sky Diploma's program). If you do do that though, remember to take away that same code from line 47.
I actually put the code in 47 Keeping in mind that there is an option for an attacker not to attack also. right
For example if the user enters something other than "A".
Hmm.... yes you're very correct. In fact, the same thing should be done to the player1 code, because if p2hp -= p1attack; is called and p1attack hasn't been initialized, you'll get not so optimal results.
So either change it, or in the beginning of the loop set p1attack and p2attack to 0.
Thanks guys, now i was wondering now if i should make it so the other player cannot make your hp a negative number, how could this be done? Please reply.
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.