S
S
Sanchek192021-03-17 23:40:04
C++ / C#
Sanchek19, 2021-03-17 23:40:04

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

1 answer(s)
S
Sergey Vodakov, 2021-03-18
@WaterSmith

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 question

Ask a Question

731 491 924 answers to any question