comparison pytouhou/game/sprite.py @ 54:b383b09bc735

Fix anim cycling
author Thibaut Girka <thib@sitedethib.com>
date Mon, 22 Aug 2011 23:43:40 +0200
parents ab826bc29aa2
children 694f25881d0f
comparison
equal deleted inserted replaced
53:e72166f73e30 54:b383b09bc735
95 return False 95 return False
96 96
97 changed = False 97 changed = False
98 if not self.keep_still: 98 if not self.keep_still:
99 script = self.anm.scripts[self.script_index] 99 script = self.anm.scripts[self.script_index]
100 try: 100 frame = self.frame
101 frame = self.frame 101 while True:
102 while frame <= self.frame: 102 try:
103 frame, instr_type, args = script[self.instruction_pointer] 103 frame, instr_type, args = script[self.instruction_pointer]
104 if frame == self.frame: 104 except IndexError:
105 changed = True 105 self.playing = False
106 if instr_type == 0: 106 return False
107 self.playing = False 107
108 return False 108 if frame > self.frame:
109 if instr_type == 1: 109 break
110 self.texcoords = self.anm.sprites[args[0]] 110 else:
111 elif instr_type == 2: 111 self.instruction_pointer += 1
112 self.rescale = args 112 if frame == self.frame:
113 elif instr_type == 3: 113 changed = True
114 self.alpha = args[0] % 256 #TODO 114 if instr_type == 0:
115 elif instr_type == 5: 115 self.playing = False
116 self.instruction_pointer, = args 116 return False
117 self.frame = script[self.instruction_pointer][0] 117 if instr_type == 1:
118 continue 118 self.texcoords = self.anm.sprites[args[0]]
119 elif instr_type == 7: 119 elif instr_type == 2:
120 self.mirrored = True 120 self.rescale = args
121 elif instr_type == 9: 121 elif instr_type == 3:
122 self.rotations_3d = args 122 self.alpha = args[0] % 256 #TODO
123 elif instr_type == 10: 123 elif instr_type == 5:
124 self.rotations_speed_3d = args 124 self.instruction_pointer, = args
125 elif instr_type == 23: 125 self.frame = script[self.instruction_pointer][0]
126 self.corner_relative_placement = True #TODO 126 elif instr_type == 7:
127 elif instr_type == 27: 127 self.mirrored = True
128 tox, toy = self.texoffsets 128 elif instr_type == 9:
129 self.texoffsets = tox + args[0], toy 129 self.rotations_3d = args
130 elif instr_type == 28: 130 elif instr_type == 10:
131 tox, toy = self.texoffsets 131 self.rotations_speed_3d = args
132 self.texoffsets = tox, toy + args[0] 132 elif instr_type == 23:
133 elif instr_type == 15: 133 self.corner_relative_placement = True #TODO
134 self.keep_still = True 134 elif instr_type == 27:
135 break 135 tox, toy = self.texoffsets
136 else: 136 self.texoffsets = tox + args[0], toy
137 print('unhandled opcode: %d, %r' % (instr_type, args)) #TODO 137 elif instr_type == 28:
138 if frame <= self.frame: 138 tox, toy = self.texoffsets
139 self.instruction_pointer += 1 139 self.texoffsets = tox, toy + args[0]
140 except IndexError: 140 elif instr_type == 15:
141 self.playing = False 141 self.keep_still = True
142 pass 142 break
143 else:
144 print('unhandled opcode: %d, %r' % (instr_type, args)) #TODO
143 self.frame += 1 145 self.frame += 1
144 146
145 ax, ay, az = self.rotations_3d 147 ax, ay, az = self.rotations_3d
146 sax, say, saz = self.rotations_speed_3d 148 sax, say, saz = self.rotations_speed_3d
147 self.rotations_3d = ax + sax, ay + say, az + saz 149 self.rotations_3d = ax + sax, ay + say, az + saz