comparison pytouhou/game/bullet.py @ 94:ca571697ec83

Various minor optimisations and refactoring
author Thibaut Girka <thib@sitedethib.com>
date Sun, 04 Sep 2011 20:04:00 +0200
parents 630e9045e851
children ac2e5e1c2c3c
comparison
equal deleted inserted replaced
93:d167280a82fc 94:ca571697ec83
95 def get_objects_by_texture(self, objects_by_texture): 95 def get_objects_by_texture(self, objects_by_texture):
96 sprite = self._sprite 96 sprite = self._sprite
97 sprite.update_vertices_uvs_colors() 97 sprite.update_vertices_uvs_colors()
98 key = sprite.anm.first_name, sprite.anm.secondary_name 98 key = sprite.anm.first_name, sprite.anm.secondary_name
99 key = (key, sprite.blendfunc) 99 key = (key, sprite.blendfunc)
100 if not key in objects_by_texture: 100 rec = objects_by_texture.setdefault(key, ([], [], []))
101 objects_by_texture[key] = (0, [], [], [])
102 vertices = ((x + self.x, y + self.y, z) for x, y, z in sprite._vertices) 101 vertices = ((x + self.x, y + self.y, z) for x, y, z in sprite._vertices)
103 objects_by_texture[key][1].extend(vertices) 102 rec[0].extend(vertices)
104 objects_by_texture[key][2].extend(sprite._uvs) 103 rec[1].extend(sprite._uvs)
105 objects_by_texture[key][3].extend(sprite._colors) 104 rec[2].extend(sprite._colors)
106 105
107 106
108 def update(self): 107 def update(self):
109 if not self._sprite or self._sprite._removed: 108 if not self._sprite or self._sprite._removed:
110 self._launched = True 109 self._launched = True
111 self._sprite = Sprite() 110 self._sprite = Sprite()
112 self._anmrunner = ANMRunner(self._game_state.resources.etama_anm_wrappers[0], #TODO 111 self._anmrunner = ANMRunner(self._game_state.resources.etama_anm_wrappers[0], #TODO
113 self.anim_idx, self._sprite, self.sprite_idx_offset) 112 self.anim_idx, self._sprite, self.sprite_idx_offset)
114 113
115 if self._anmrunner and not self._anmrunner.run_frame(): 114 self._anmrunner.run_frame()
116 self._anmrunner = None
117
118 self._sprite.update(angle_base=self.angle) 115 self._sprite.update(angle_base=self.angle)
119 116
120 #TODO: flags 117 #TODO: flags
121 x, y = self.x, self.y 118 x, y = self.x, self.y
122 119