# HG changeset patch # User Thibaut Girka # Date 1325294151 -3600 # Node ID 8843e26f80c387fb7d3ea2f4a675fccfad7945e8 # Parent c417bb6c98bfab3c114712c414c971d2d3cdd506 Hopefully implement “accelerating” bullets diff --git a/pytouhou/game/bullet.py b/pytouhou/game/bullet.py --- a/pytouhou/game/bullet.py +++ b/pytouhou/game/bullet.py @@ -21,7 +21,7 @@ from pytouhou.game.sprite import Sprite class Bullet(object): def __init__(self, pos, bullet_type, sprite_idx_offset, - angle, speed, attributes, flags, player, game, + angle, speed, attributes, flags, target, game, player_bullet=False, damage=0, hitbox=None): self._game = game self._sprite = None @@ -39,7 +39,7 @@ class Bullet(object): self.frame = 0 self.grazed = False - self.player = player + self.target = target self.sprite_idx_offset = sprite_idx_offset @@ -217,7 +217,7 @@ class Bullet(object): if self.flags & 64: self.angle += angle elif self.flags & 128: - self.angle = atan2(self.player.y - y, self.player.x - x) + angle + self.angle = atan2(self.target.y - y, self.target.x - x) + angle elif self.flags & 256: self.angle = angle diff --git a/pytouhou/games/eosd.py b/pytouhou/games/eosd.py --- a/pytouhou/games/eosd.py +++ b/pytouhou/games/eosd.py @@ -132,21 +132,32 @@ class EoSDPlayer(Player): nb_bullets_max = self._game.nb_bullets_max for shot in sht.shots[power]: - if shot.type in (2, 3): # TODO: Those shot types aren't handled yet + if shot.type == 3: # TODO: Lasers aren't implemented yet + continue + + if self.fire_time % shot.interval != shot.delay: continue - if self.fire_time % shot.interval == shot.delay: - if nb_bullets_max is not None and len(bullets) == nb_bullets_max: - break + if nb_bullets_max is not None and len(bullets) == nb_bullets_max: + break + + origin = self.orbs[shot.orb - 1] if shot.orb else self + x = origin.x + shot.pos[0] + y = origin.y + shot.pos[1] - origin = self.orbs[shot.orb - 1] if shot.orb else self - x = origin.x + shot.pos[0] - y = origin.y + shot.pos[1] - - #TODO: find a better way to do that. - bullet_type = BulletType(self.anm_wrapper, shot.sprite % 256, - shot.sprite % 256 + 32, #TODO: find the real cancel anim - 0, 0, 0, 0.) + #TODO: find a better way to do that. + bullet_type = BulletType(self.anm_wrapper, shot.sprite % 256, + shot.sprite % 256 + 32, #TODO: find the real cancel anim + 0, 0, 0, 0.) + if shot.type == 2: + #TODO: check acceleration, check duration, check everything! + bullets.append(Bullet((x, y), bullet_type, 0, + shot.angle, shot.speed, + (-1, 0, 0, 0, 0.15, -pi/2., 0., 0.), + 16, self, self._game, player_bullet=True, + damage=shot.damage, hitbox=shot.hitbox)) + #TODO: types 1 and 4 + else: bullets.append(Bullet((x, y), bullet_type, 0, shot.angle, shot.speed, (0, 0, 0, 0, 0., 0., 0., 0.), diff --git a/pytouhou/games/pcb.py b/pytouhou/games/pcb.py --- a/pytouhou/games/pcb.py +++ b/pytouhou/games/pcb.py @@ -139,4 +139,5 @@ class PCBPlayer(Player): bullets.append(Bullet((x, y), self.bullet_type, 0, shot.angle, shot.speed, (0, 0, 0, 0, 0., 0., 0., 0.), - 0, self, self._game, player_bullet=True, damage=shot.damage, hitbox=shot.hitbox)) + 0, self, self._game, player_bullet=True, + damage=shot.damage, hitbox=shot.hitbox))