Mercurial > touhou
diff pytouhou/game/enemy.py @ 274:f037bca24f2d
Partially implement lasers.
“Launch animations”/“energy circles” are missing, aswell as collision and grazing.
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Sun, 05 Feb 2012 23:41:55 +0100 |
parents | 7a9135b88853 |
children | 219edad0f395 |
line wrap: on
line diff
--- a/pytouhou/game/enemy.py +++ b/pytouhou/game/enemy.py @@ -17,6 +17,7 @@ from pytouhou.utils.interpolator import from pytouhou.vm.anmrunner import ANMRunner from pytouhou.game.sprite import Sprite from pytouhou.game.bullet import Bullet +from pytouhou.game.laser import Laser from pytouhou.game.effect import Effect from math import cos, sin, atan2, pi @@ -46,6 +47,8 @@ class Enemy(object): self.boss = False self.difficulty_coeffs = (-.5, .5, 0, 0, 0, 0) self.extended_bullet_attributes = (0, 0, 0, 0, 0., 0., 0., 0.) + self.current_laser_id = 0 + self.laser_by_id = {} self.bullet_attributes = None self.bullet_launch_offset = (0, 0) self.death_callback = -1 @@ -161,6 +164,22 @@ class Enemy(object): bullet_angle += angle + def new_laser(self, variant, laser_type, sprite_idx_offset, angle, speed, + start_offset, end_offset, max_length, width, + start_duration, duration, end_duration, + grazing_delay, grazing_extra_duration, unknown): + launch_pos = self.x, self.y + if variant == 86: + angle += self.get_player_angle(self.select_player(), launch_pos) + laser = Laser(launch_pos, self._game.laser_types[laser_type], + sprite_idx_offset, angle, speed, + start_offset, end_offset, max_length, width, + start_duration, duration, end_duration, grazing_delay, + grazing_extra_duration, self._game) + self._game.lasers.append(laser) + self.laser_by_id[self.current_laser_id] = laser + + def select_player(self, players=None): return (players or self._game.players)[0] #TODO