Mercurial > touhou
comparison pytouhou/game/bullet.py @ 149:3673d55a8448
Fix bullet flags 16 and 32 handling
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Tue, 04 Oct 2011 18:13:26 +0200 |
parents | 30338dc33a7b |
children | 5cf927cbd9c5 |
comparison
equal
deleted
inserted
replaced
148:6460814b68ea | 149:3673d55a8448 |
---|---|
131 #TODO: flags | 131 #TODO: flags |
132 x, y = self.x, self.y | 132 x, y = self.x, self.y |
133 dx, dy = self.delta | 133 dx, dy = self.delta |
134 | 134 |
135 if self.flags & 16: | 135 if self.flags & 16: |
136 frame, count = self.attributes[0:2] | |
137 length, angle = self.attributes[4:6] | 136 length, angle = self.attributes[4:6] |
138 angle = self.angle if angle < -900.0 else angle #TODO: is that right? | 137 angle = self.angle if angle < -900.0 else angle #TODO: is that right? |
139 dx, dy = dx + cos(angle) * length, dy + sin(angle) * length | 138 dx, dy = dx + cos(angle) * length, dy + sin(angle) * length |
140 self.angle = sprite.angle = atan2(dy, dx) | 139 self.angle = sprite.angle = atan2(dy, dx) |
141 if sprite.automatic_orientation: | 140 if sprite.automatic_orientation: |
142 sprite._changed = True | 141 sprite._changed = True |
143 self.delta = dx, dy | 142 self.delta = dx, dy |
144 if self.frame == frame: #TODO: include last frame, or not? | 143 if self.frame == self.attributes[0]: #TODO: include last frame, or not? |
145 if count > 0: | 144 self.flags ^= 16 |
146 self.attributes[1] -= 1 | |
147 self.frame = 0 | |
148 else: | |
149 self.flags ^= 16 | |
150 elif self.flags & 32: | 145 elif self.flags & 32: |
151 #TODO: check | 146 #TODO: check |
152 frame, count = self.attributes[0:2] | |
153 acceleration, angular_speed = self.attributes[4:6] | 147 acceleration, angular_speed = self.attributes[4:6] |
154 self.speed += acceleration | 148 self.speed += acceleration |
155 self.angle += angular_speed | 149 self.angle += angular_speed |
156 dx, dy = cos(self.angle) * self.speed, sin(self.angle) * self.speed | 150 dx, dy = cos(self.angle) * self.speed, sin(self.angle) * self.speed |
157 self.delta = dx, dy | 151 self.delta = dx, dy |
158 sprite.angle = self.angle | 152 sprite.angle = self.angle |
159 if sprite.automatic_orientation: | 153 if sprite.automatic_orientation: |
160 sprite._changed = True | 154 sprite._changed = True |
161 if self.frame % frame == 0: | 155 if self.frame == self.attributes[0]: |
162 if count >= 0: | 156 self.flags ^= 32 |
163 self.attributes[1] -= 1 | |
164 else: | |
165 self.flags ^= 32 | |
166 elif self.flags & 448: | 157 elif self.flags & 448: |
167 #TODO: check | 158 #TODO: check |
168 frame, count = self.attributes[0:2] | 159 frame, count = self.attributes[0:2] |
169 angle, speed = self.attributes[4:6] | 160 angle, speed = self.attributes[4:6] |
170 if self.frame % frame == 0: | 161 if self.frame % frame == 0: |