Mercurial > touhou
comparison pytouhou/game/sprite.py @ 27:b65d6bc55793
Add rotating sprite support
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Fri, 12 Aug 2011 21:38:28 +0200 |
parents | f17122405121 |
children | f405b947624d |
comparison
equal
deleted
inserted
replaced
26:f17122405121 | 27:b65d6bc55793 |
---|---|
20 self.script_index = script_index | 20 self.script_index = script_index |
21 self.texcoords = (0, 0, 0, 0) # x, y, width, height | 21 self.texcoords = (0, 0, 0, 0) # x, y, width, height |
22 self.mirrored = False | 22 self.mirrored = False |
23 self.rescale = (1., 1.) | 23 self.rescale = (1., 1.) |
24 self.rotations_3d = (0., 0., 0.) | 24 self.rotations_3d = (0., 0., 0.) |
25 self.rotations_speed_3d = (0., 0., 0.) | |
25 self.corner_relative_placement = False | 26 self.corner_relative_placement = False |
26 self.frame = 0 | 27 self.frame = 0 |
27 self._uvs = [] | 28 self._uvs = [] |
28 self._vertices = [] | 29 self._vertices = [] |
29 | 30 |
87 break | 88 break |
88 else: | 89 else: |
89 properties[instr_type] = data | 90 properties[instr_type] = data |
90 self.frame += 1 | 91 self.frame += 1 |
91 | 92 |
93 self.rotations_3d = tuple(x + y for x, y in zip(self.rotations_3d, self.rotations_speed_3d)) | |
94 | |
92 if properties: | 95 if properties: |
93 if 1 in properties: | 96 if 1 in properties: |
94 self.texcoords = self.anm.sprites[unpack('<I', properties[1])[0]] | 97 self.texcoords = self.anm.sprites[unpack('<I', properties[1])[0]] |
95 del properties[1] | 98 del properties[1] |
96 if 2 in properties: | 99 if 2 in properties: |
103 self.mirrored = True #TODO | 106 self.mirrored = True #TODO |
104 del properties[7] | 107 del properties[7] |
105 if 9 in properties: | 108 if 9 in properties: |
106 self.rotations_3d = unpack('<fff', properties[9]) | 109 self.rotations_3d = unpack('<fff', properties[9]) |
107 del properties[9] | 110 del properties[9] |
111 if 10 in properties: | |
112 self.rotations_speed_3d = unpack('<fff', properties[10]) | |
113 del properties[10] | |
108 if 23 in properties: | 114 if 23 in properties: |
109 self.corner_relative_placement = True #TODO | 115 self.corner_relative_placement = True #TODO |
110 del properties[23] | 116 del properties[23] |
111 if properties: | 117 if properties: |
112 print('Leftover properties: %r' % properties) #TODO | 118 print('Leftover properties: %r' % properties) #TODO |
113 self.update_uvs_vertices(override_width, override_height) | 119 self.update_uvs_vertices(override_width, override_height) |
114 return True | 120 return True |
121 if self.rotations_speed_3d != (0., 0., 0.): | |
122 self.update_uvs_vertices(override_width, override_height) | |
123 return True | |
115 return False | 124 return False |
116 | 125 |