comparison pytouhou/game/bullet.py @ 236:741860192b56

Implement ANM0 interrupts “Instruction” 22 is used as a label for interrupts. If the normal animation is interrupted, it goes straight to the matched instruction. Interrupt -1 matches all interrupts.
author Thibaut Girka <thib@sitedethib.com>
date Sun, 01 Jan 2012 19:47:34 +0100
parents 8843e26f80c3
children cb329dca4758
comparison
equal deleted inserted replaced
235:e59bd7979ddc 236:741860192b56
15 from math import cos, sin, atan2, pi 15 from math import cos, sin, atan2, pi
16 16
17 from pytouhou.utils.interpolator import Interpolator 17 from pytouhou.utils.interpolator import Interpolator
18 from pytouhou.vm.anmrunner import ANMRunner 18 from pytouhou.vm.anmrunner import ANMRunner
19 from pytouhou.game.sprite import Sprite 19 from pytouhou.game.sprite import Sprite
20
20 21
21 22
22 class Bullet(object): 23 class Bullet(object):
23 def __init__(self, pos, bullet_type, sprite_idx_offset, 24 def __init__(self, pos, bullet_type, sprite_idx_offset,
24 angle, speed, attributes, flags, target, game, 25 angle, speed, attributes, flags, target, game,
184 185
185 if self.flags & 16: 186 if self.flags & 16:
186 length, angle = self.attributes[4:6] 187 length, angle = self.attributes[4:6]
187 angle = self.angle if angle < -900.0 else angle #TODO: is that right? 188 angle = self.angle if angle < -900.0 else angle #TODO: is that right?
188 dx, dy = dx + cos(angle) * length, dy + sin(angle) * length 189 dx, dy = dx + cos(angle) * length, dy + sin(angle) * length
190 self.speed = (dx ** 2 + dy ** 2) ** 0.5
189 self.angle = sprite.angle = atan2(dy, dx) 191 self.angle = sprite.angle = atan2(dy, dx)
190 if sprite.automatic_orientation: 192 if sprite.automatic_orientation:
191 sprite._changed = True 193 sprite._changed = True
192 self.delta = dx, dy 194 self.delta = dx, dy
193 if self.frame == self.attributes[0]: #TODO: include last frame, or not? 195 if self.frame == self.attributes[0]: #TODO: include last frame, or not?