comparison pytouhou/game/bullet.py @ 85:3804f07d3b0e

Various optimizations
author Thibaut Girka <thib@sitedethib.com>
date Sat, 03 Sep 2011 23:34:12 +0200
parents 1a0c78e5a941
children a87a3c080585
comparison
equal deleted inserted replaced
84:1a0c78e5a941 85:3804f07d3b0e
71 max_y < -self.y)): 71 max_y < -self.y)):
72 return False 72 return False
73 return True 73 return True
74 74
75 75
76 def get_objects_by_texture(self): 76 def get_objects_by_texture(self, objects_by_texture):
77 objects_by_texture = {} 77 sprite = self._sprite
78 key = self._sprite.anm.first_name, self._sprite.anm.secondary_name 78 key = sprite.anm.first_name, sprite.anm.secondary_name
79 key = (key, self._sprite.blendfunc) 79 key = (key, sprite.blendfunc)
80 if not key in objects_by_texture: 80 if not key in objects_by_texture:
81 objects_by_texture[key] = (0, [], [], []) 81 objects_by_texture[key] = (0, [], [], [])
82 vertices = tuple((x + self.x, y + self.y, z) for x, y, z in self._sprite._vertices) 82 vertices = ((x + self.x, y + self.y, z) for x, y, z in sprite._vertices)
83 objects_by_texture[key][1].extend(vertices) 83 objects_by_texture[key][1].extend(vertices)
84 objects_by_texture[key][2].extend(self._sprite._uvs) 84 objects_by_texture[key][2].extend(sprite._uvs)
85 objects_by_texture[key][3].extend(self._sprite._colors) 85 objects_by_texture[key][3].extend(sprite._colors)
86 return objects_by_texture
87 86
88 87
89 def update(self): 88 def update(self):
90 if not self._sprite or self._sprite._removed: 89 if not self._sprite or self._sprite._removed:
91 self._launched = True 90 self._launched = True
95 #TODO: self._anmrunner.sprite_idx_offset = self.sprite_idx_offset 94 #TODO: self._anmrunner.sprite_idx_offset = self.sprite_idx_offset
96 95
97 if self._anmrunner and not self._anmrunner.run_frame(): 96 if self._anmrunner and not self._anmrunner.run_frame():
98 self._anmrunner = None 97 self._anmrunner = None
99 98
100 if self._sprite: 99 self._sprite.update()
101 self._sprite.update() 100 if self._sprite._changed: #TODO
102 if self._sprite._changed: #TODO 101 angle = pi/2.-self.angle if self._sprite.automatic_orientation else 0.
103 angle = pi/2.-self.angle if self._sprite.automatic_orientation else 0. 102 self._sprite.update_vertices_uvs_colors(angle_base=angle)
104 self._sprite.update_vertices_uvs_colors(angle_base=angle)
105 103
106 #TODO: flags 104 #TODO: flags
107 x, y = self.x, self.y 105 x, y = self.x, self.y
108 106
109 dx, dy = cos(self.angle) * self.speed, sin(self.angle) * self.speed 107 dx, dy = cos(self.angle) * self.speed, sin(self.angle) * self.speed