Ejemplo n.º 1
0
 def update_image(self, world):
     xvel = Game.cutoff(self.vel[0], 0.01)
     yvel = Game.cutoff(self.vel[1], 0.01)
     
     if xvel != 0 or yvel != 0:
         self.update_anim_timer(True, world)
         
         if xvel < 0:
             self.transition_to_anim_dir(0, world)
         elif xvel > 0:
             self.transition_to_anim_dir(2, world)
         elif yvel < 0:
             self.transition_to_anim_dir(1, world)
         elif yvel > 0:
             self.transition_to_anim_dir(3, world)
     
     else:
         if self.facing == Game.LEFT:
             anim_dir = 0
         else:
             anim_dir = 1
         self.transition_to_anim(0, anim_dir, world)
         if self.anim_state != 0:
             self.update_anim_timer(False, world)
     
     self.img = self.body_images[self.anim_state][self.anim_dir]
     self.hair_img = self.hair_images[self.anim_state][self.anim_dir]
     self.tail_img = self.tail_images[self.anim_state][self.anim_dir]
Ejemplo n.º 2
0
 def update(self, world):
     if self.hurt_time > -1:
         if self.hurt_time == 0:
             self.hurt = False
         self.hurt_time -= 1
     self.knockback[0] = Game.cutoff(self.knockback[0], ent.DamageSource.KNOCKBACK_FALLOFF)
     self.knockback[1] = Game.cutoff(self.knockback[1], ent.DamageSource.KNOCKBACK_FALLOFF)
     if self.knockback[0] != 0:
         self.vel[0] += self.knockback[0]
         self.knockback[0] += math.copysign(ent.DamageSource.KNOCKBACK_FALLOFF, -self.knockback[0])
     if self.knockback[1] != 0:
         self.vel[1] += self.knockback[1]
         self.knockback[1] += math.copysign(ent.DamageSource.KNOCKBACK_FALLOFF, -self.knockback[1])
     super().update(world)