lundi 5 septembre 2016

How to constantly execute an if statement

I guess it is not possible, but I just wanted to know if it could be possible to have an if statement always "active". I am creating a text-based game and the health variable of the character is changing often, so when it reaches 0 or below, i want to execute a "dead" function.

if (health < 1) {
  //code
};

Do I have to include that if-statement everytime in the object, when the health variable changes?

Thank you a lot :)

Aucun commentaire:

Enregistrer un commentaire