Changeset 242:c30fcf903d29


Ignore:
Timestamp:
04/07/11 13:01:23 (12 years ago)
Author:
Neil Muller <drnlmuller@…>
Branch:
default
Phase:
public
Rebase:
35643230343132346164333630333766653162356466616632326337623937393735336362663161
Message:

Add update force parameter, so we can transition out of attacking animations even if it introduce a new collision

File:
1 edited

Legend:

Unmodified
Added
Removed
  • skaapsteker/sprites/base.py

    r241 r242  
    8181        self.setup(**opts)
    8282
    83     def _update_image(self):
     83    def _update_image(self, force=False):
    8484        if self.facing:
    8585            images = self._animations[self._animation][self.facing]
     
    9898        cand_collide_rect.midbottom = cur_pos
    9999
    100         if not self.check_collide_rect(cand_collide_rect, cand_rect, cand_image) and not self._animation == 'attacking':
     100        if not self.check_collide_rect(cand_collide_rect, cand_rect, cand_image) and not force:
    101101            return
    102102
     
    111111            self._tick = 0
    112112            self._frame += 1
    113             self._update_image()
     113            force = False
     114            if self._animation == 'attacking':
     115                force = True
     116            self._update_image(force)
    114117        self._tick += 1
    115118
     
    147150                self._animation = self._old_state
    148151                self.facing = self._old_facing
    149                 self._update_image()
     152                self._update_image(True)
    150153            elif self._frame == self.attack_frame and self._tick == 5:
    151154                # Attack the player
     
    167170            self._tick = 1
    168171            self._frame = 0  # Start the attack from the beginning
    169             self._update_image()
     172            self._update_image(True)
    170173        else:
    171174            player.damage(1)  # collision damage
Note: See TracChangeset for help on using the changeset viewer.