( health ) Variables ain't working as it should be


#1

Hey there is a bug about health’s variable in while loop

if i made the code as this:

    hp = self.health
    fullhp = self.maxHealth
    while hp >= fullhp :
        self.say("You stupid Ogres LOL!")
   move

it stuck inside an inf loop

but if i make it as this

while self.health >= self.maxHealth :
    self.say("You stupid Ogres LOL!")
self.moveXY(22, 15)

it does works , try it yourself , and sorry for my bad english tough


#2

It’s because you redefined the variable. it never changes unless you change it.

you’d have to do something inside the while loop like

while hp >= fullhp:
    hp = self.health

#3

Also, since hp is never > maxHealth, can just compare them as:

while hp == fullhp: