comparison pytouhou/game/sprite.py @ 17:d940d004b840

Make game.sprite.Sprite use its own frame counter.
author Thibaut Girka <thib@sitedethib.com>
date Tue, 09 Aug 2011 11:40:13 +0200
parents 07fba4e1da65
children bf225780973f
comparison
equal deleted inserted replaced
16:66ce9bb440ac 17:d940d004b840
9 self.texcoords = (0, 0, 0, 0) # x, y, width, height 9 self.texcoords = (0, 0, 0, 0) # x, y, width, height
10 self.mirrored = False 10 self.mirrored = False
11 self.rescale = (1., 1.) 11 self.rescale = (1., 1.)
12 self.rotations_3d = (0., 0., 0.) 12 self.rotations_3d = (0., 0., 0.)
13 self.corner_relative_placement = False 13 self.corner_relative_placement = False
14 self.frame = 0
14 self._uvs = [] 15 self._uvs = []
15 self._vertices = [] 16 self._vertices = []
16 17
17 18
18 def update_uvs_vertices(self, override_width=0, override_height=0): 19 def update_uvs_vertices(self, override_width=0, override_height=0):
64 65
65 self._uvs, self._vertices = uvs, vertices 66 self._uvs, self._vertices = uvs, vertices
66 67
67 68
68 69
69 def update(self, frame, override_width=0, override_height=0): 70 def update(self, override_width=0, override_height=0):
70 properties = {} 71 properties = {}
71 for time, instr_type, data in self.anm.scripts[self.script_index]: 72 for time, instr_type, data in self.anm.scripts[self.script_index]:
72 if time == frame: 73 if time == self.frame:
73 if instr_type == 15: #Return 74 if instr_type == 15: #Return
74 break 75 break
75 else: 76 else:
76 properties[instr_type] = data 77 properties[instr_type] = data
78 self.frame += 1
79
77 if properties: 80 if properties:
78 if 1 in properties: 81 if 1 in properties:
79 self.texcoords = self.anm.sprites[unpack('<I', properties[1])[0]] 82 self.texcoords = self.anm.sprites[unpack('<I', properties[1])[0]]
80 del properties[1] 83 del properties[1]
81 if 2 in properties: 84 if 2 in properties: