comparison 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
comparison
equal deleted inserted replaced
273:595b227886b1 274:f037bca24f2d
15 15
16 from pytouhou.utils.interpolator import Interpolator 16 from pytouhou.utils.interpolator import Interpolator
17 from pytouhou.vm.anmrunner import ANMRunner 17 from pytouhou.vm.anmrunner import ANMRunner
18 from pytouhou.game.sprite import Sprite 18 from pytouhou.game.sprite import Sprite
19 from pytouhou.game.bullet import Bullet 19 from pytouhou.game.bullet import Bullet
20 from pytouhou.game.laser import Laser
20 from pytouhou.game.effect import Effect 21 from pytouhou.game.effect import Effect
21 from math import cos, sin, atan2, pi 22 from math import cos, sin, atan2, pi
22 23
23 24
24 class Enemy(object): 25 class Enemy(object):
44 self.damageable = True 45 self.damageable = True
45 self.death_flags = 0 46 self.death_flags = 0
46 self.boss = False 47 self.boss = False
47 self.difficulty_coeffs = (-.5, .5, 0, 0, 0, 0) 48 self.difficulty_coeffs = (-.5, .5, 0, 0, 0, 0)
48 self.extended_bullet_attributes = (0, 0, 0, 0, 0., 0., 0., 0.) 49 self.extended_bullet_attributes = (0, 0, 0, 0, 0., 0., 0., 0.)
50 self.current_laser_id = 0
51 self.laser_by_id = {}
49 self.bullet_attributes = None 52 self.bullet_attributes = None
50 self.bullet_launch_offset = (0, 0) 53 self.bullet_launch_offset = (0, 0)
51 self.death_callback = -1 54 self.death_callback = -1
52 self.boss_callback = None 55 self.boss_callback = None
53 self.low_life_callback = -1 56 self.low_life_callback = -1
157 bullets.append(Bullet(launch_pos, bullet_type, sprite_idx_offset, 160 bullets.append(Bullet(launch_pos, bullet_type, sprite_idx_offset,
158 bullet_angle, shot_speed, 161 bullet_angle, shot_speed,
159 self.extended_bullet_attributes, 162 self.extended_bullet_attributes,
160 flags, player, self._game)) 163 flags, player, self._game))
161 bullet_angle += angle 164 bullet_angle += angle
165
166
167 def new_laser(self, variant, laser_type, sprite_idx_offset, angle, speed,
168 start_offset, end_offset, max_length, width,
169 start_duration, duration, end_duration,
170 grazing_delay, grazing_extra_duration, unknown):
171 launch_pos = self.x, self.y
172 if variant == 86:
173 angle += self.get_player_angle(self.select_player(), launch_pos)
174 laser = Laser(launch_pos, self._game.laser_types[laser_type],
175 sprite_idx_offset, angle, speed,
176 start_offset, end_offset, max_length, width,
177 start_duration, duration, end_duration, grazing_delay,
178 grazing_extra_duration, self._game)
179 self._game.lasers.append(laser)
180 self.laser_by_id[self.current_laser_id] = laser
162 181
163 182
164 def select_player(self, players=None): 183 def select_player(self, players=None):
165 return (players or self._game.players)[0] #TODO 184 return (players or self._game.players)[0] #TODO
166 185