comparison pytouhou/game/enemymanager.py @ 73:e4af16a019d3

Do not remove enemies as soon as they lose their animation (Daiyousei...)
author Thibaut Girka <thib@sitedethib.com>
date Sun, 28 Aug 2011 11:20:16 +0200
parents 6a08f44fa01b
children b3bd421bb895
comparison
equal deleted inserted replaced
72:6a08f44fa01b 73:e4af16a019d3
117 self.speed_interpolator.set_interpolation_start(self.frame, (self.speed,)) 117 self.speed_interpolator.set_interpolation_start(self.frame, (self.speed,))
118 self.speed_interpolator.set_interpolation_end(self.frame + duration, (0.,)) 118 self.speed_interpolator.set_interpolation_end(self.frame + duration, (0.,))
119 119
120 120
121 def is_visible(self, screen_width, screen_height): 121 def is_visible(self, screen_width, screen_height):
122 if not self._sprite: 122 if self._sprite:
123 return False 123 tx, ty, tw, th = self._sprite.texcoords
124 124 if self._sprite.corner_relative_placement:
125 tx, ty, tw, th = self._sprite.texcoords 125 raise Exception #TODO
126 if self._sprite.corner_relative_placement:
127 raise Exception #TODO
128 else: 126 else:
129 max_x = tw / 2. 127 tx, ty, tw, th = 0., 0., 0., 0.
130 max_y = th / 2. 128
131 min_x = -max_x 129 max_x = tw / 2.
132 min_y = -max_y 130 max_y = th / 2.
131 min_x = -max_x
132 min_y = -max_y
133 133
134 if any((min_x > screen_width - self.x, 134 if any((min_x > screen_width - self.x,
135 max_x < -self.x, 135 max_x < -self.x,
136 min_y > screen_height - self.y, 136 min_y > screen_height - self.y,
137 max_y < -self.y)): 137 max_y < -self.y)):
138 return False 138 return False
139 return True 139 return True
140 140
141 141
142 def get_objects_by_texture(self): 142 def get_objects_by_texture(self):
143 if not self._sprite:
144 return {}
145
143 objects_by_texture = {} 146 objects_by_texture = {}
144 key = self._sprite.anm.first_name, self._sprite.anm.secondary_name 147 key = self._sprite.anm.first_name, self._sprite.anm.secondary_name
145 key = (key, self._sprite.blendfunc) 148 key = (key, self._sprite.blendfunc)
146 if not key in objects_by_texture: 149 if not key in objects_by_texture:
147 objects_by_texture[key] = (0, [], [], []) 150 objects_by_texture[key] = (0, [], [], [])