Mercurial > skaapsteker
comparison skaapsteker/sprites/player.py @ 627:35919d12b792
Path-based collision minimisation and axis-projection backout.
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Sat, 07 May 2011 20:28:06 +0200 |
parents | 65881746dc20 |
children | 1fdfc7f03d98 |
comparison
equal
deleted
inserted
replaced
626:1abb53ae1a6a | 627:35919d12b792 |
---|---|
39 'lightning': [ time.time(), lambda : 2.0 / len(self._me.tails) ], | 39 'lightning': [ time.time(), lambda : 2.0 / len(self._me.tails) ], |
40 'shield': [ time.time(), lambda : 16.0 / len(self._me.tails) ], | 40 'shield': [ time.time(), lambda : 16.0 / len(self._me.tails) ], |
41 } | 41 } |
42 self._inv_cache = {} # invisible fox image cache | 42 self._inv_cache = {} # invisible fox image cache |
43 self._shield_cache = {} # shielded fox image cache | 43 self._shield_cache = {} # shielded fox image cache |
44 self._shield_image = 0 # shield image | |
45 # State flags and such | 44 # State flags and such |
46 self.attacking = 0 | 45 self.attacking = 0 |
47 self.running = False | 46 self.running = False |
48 self.sprinting = 0 | 47 self.sprinting = 0 |
49 self.jumping = False | 48 self.jumping = False |
118 cur_pos = self.collide_rect.midbottom | 117 cur_pos = self.collide_rect.midbottom |
119 else: | 118 else: |
120 cur_pos = (0, 0) | 119 cur_pos = (0, 0) |
121 # TODO: can save a lot of calculation here by caching collision rects | 120 # TODO: can save a lot of calculation here by caching collision rects |
122 cand_image = images[int(self._animation_frame)] | 121 cand_image = images[int(self._animation_frame)] |
123 cand_collide_rect = cand_image.get_bounding_rect(1).inflate(-2,-2) | 122 # cand_collide_rect = cand_image.get_bounding_rect(1).inflate(-2,-2) |
123 cand_collide_rect = cand_image.get_bounding_rect(1) | |
124 cand_rect = cand_image.get_rect() | 124 cand_rect = cand_image.get_rect() |
125 cand_rect_offset = cand_rect.centerx - cand_collide_rect.centerx, cand_rect.bottom - cand_collide_rect.bottom | 125 cand_rect_offset = cand_rect.centerx - cand_collide_rect.centerx, cand_rect.bottom - cand_collide_rect.bottom |
126 cand_rect.midbottom = cur_pos[0] + cand_rect_offset[0], cur_pos[1] + cand_rect_offset[1] | 126 cand_rect.midbottom = cur_pos[0] + cand_rect_offset[0], cur_pos[1] + cand_rect_offset[1] |
127 cand_collide_rect.midbottom = cur_pos | 127 cand_collide_rect.midbottom = cur_pos |
128 # We always allow the attacking animation frames | 128 # We always allow the attacking animation frames |