Reply To: Could you go into if (damage >= currentHealth) { is for? Won't this lead to the player dying prematurely – while…

Forum Archive Could you go into if (damage >= currentHealth) { is for? Won't this lead to the player dying prematurely – while… Reply To: Could you go into if (damage >= currentHealth) { is for? Won't this lead to the player dying prematurely – while…

#25044
Jonathan Gonzalez
Participant

    The if statement was included to prevent going into a negative state but I could’ve also just added “currentHealth = 0” up above where we check to see if our health is equal to or below health.

    Regarding the double deduction, I believe you’re right. We’re deducting the damage amount and also checking the value of “damage” . Even if it was placed above the deduction section it’ll do the same thing.