Mercurial > touhou
comparison pytouhou/game/bullet.py @ 232:8843e26f80c3
Hopefully implement “accelerating” bullets
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Sat, 31 Dec 2011 02:15:51 +0100 |
parents | 0595315d3880 |
children | 741860192b56 |
comparison
equal
deleted
inserted
replaced
231:c417bb6c98bf | 232:8843e26f80c3 |
---|---|
19 from pytouhou.game.sprite import Sprite | 19 from pytouhou.game.sprite import Sprite |
20 | 20 |
21 | 21 |
22 class Bullet(object): | 22 class Bullet(object): |
23 def __init__(self, pos, bullet_type, sprite_idx_offset, | 23 def __init__(self, pos, bullet_type, sprite_idx_offset, |
24 angle, speed, attributes, flags, player, game, | 24 angle, speed, attributes, flags, target, game, |
25 player_bullet=False, damage=0, hitbox=None): | 25 player_bullet=False, damage=0, hitbox=None): |
26 self._game = game | 26 self._game = game |
27 self._sprite = None | 27 self._sprite = None |
28 self._anmrunner = None | 28 self._anmrunner = None |
29 self._removed = False | 29 self._removed = False |
37 | 37 |
38 self.speed_interpolator = None | 38 self.speed_interpolator = None |
39 self.frame = 0 | 39 self.frame = 0 |
40 self.grazed = False | 40 self.grazed = False |
41 | 41 |
42 self.player = player | 42 self.target = target |
43 | 43 |
44 self.sprite_idx_offset = sprite_idx_offset | 44 self.sprite_idx_offset = sprite_idx_offset |
45 | 45 |
46 self.flags = flags | 46 self.flags = flags |
47 self.attributes = list(attributes) | 47 self.attributes = list(attributes) |
215 self.speed = speed | 215 self.speed = speed |
216 | 216 |
217 if self.flags & 64: | 217 if self.flags & 64: |
218 self.angle += angle | 218 self.angle += angle |
219 elif self.flags & 128: | 219 elif self.flags & 128: |
220 self.angle = atan2(self.player.y - y, self.player.x - x) + angle | 220 self.angle = atan2(self.target.y - y, self.target.x - x) + angle |
221 elif self.flags & 256: | 221 elif self.flags & 256: |
222 self.angle = angle | 222 self.angle = angle |
223 | 223 |
224 dx, dy = cos(self.angle) * speed, sin(self.angle) * speed | 224 dx, dy = cos(self.angle) * speed, sin(self.angle) * speed |
225 self.delta = dx, dy | 225 self.delta = dx, dy |