Answer the question
In order to leave comments, you need to log in
How to take a hit?
Tell me how to make an alternate blow, that is, so that the hero would first deal damage to the enemy, after which the enemy to the hero, and so on until the HP of one of the participants becomes zero. I would like some code
Answer the question
In order to leave comments, you need to log in
Well, here's some code for you.
while (player.hitpoints > 0 && enemy.hitpoints > 0) {
enemy.hitpoints = enemy.hitpoints - player.getDamagePower()
if (enemy.hitpoints>0) {
player.hitpoints = player.hitpoints - enemy.getDamagePower()
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question