# HG changeset patch # User Thibaut Girka # Date 1313090498 -7200 # Node ID fa87db09fc3ac62adfcc71765633922dfb450e9e # Parent bf225780973faf2f25685234b4bd26259fc80917 Fix Rumia's animations diff --git a/pytouhou/game/enemymanager.py b/pytouhou/game/enemymanager.py --- a/pytouhou/game/enemymanager.py +++ b/pytouhou/game/enemymanager.py @@ -19,6 +19,7 @@ class Enemy(object): self.sprite = None self.movement_dependant_sprites = None + self.direction = None self.interpolator = None #TODO self.angle = 0. self.speed = 0. @@ -37,7 +38,9 @@ class Enemy(object): script_index, = unpack(' abs(dy): - if dx < 0: - self.anm, self.sprite = self.anm_wrapper.get_sprite(self.movement_dependant_sprites[2]) - else: - self.anm, self.sprite = self.anm_wrapper.get_sprite(self.movement_dependant_sprites[3]) - else: - if dy < 0: - self.anm, self.sprite = self.anm_wrapper.get_sprite(self.movement_dependant_sprites[1]) - else: - self.anm, self.sprite = self.anm_wrapper.get_sprite(self.movement_dependant_sprites[2]) + if x < self.x: + self.anm, self.sprite = self.anm_wrapper.get_sprite(self.movement_dependant_sprites[2]) + self.direction = -1 + elif x > self.x: + self.anm, self.sprite = self.anm_wrapper.get_sprite(self.movement_dependant_sprites[3]) + self.direction = +1 + #TODO: end_animation + elif self.direction is not None: + self.anm, self.sprite = self.anm_wrapper.get_sprite(self.movement_dependant_sprites[{-1: 0, +1:1}[self.direction]]) + self.direction = None self.x, self.y = x, y if self.sprite: