Mercurial > touhou
comparison pytouhou/game/player.py @ 294:94c636f8f863
Add player lasers for MarisaB.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Tue, 21 Feb 2012 14:28:38 +0100 |
parents | f037bca24f2d |
children | 647bde10353d |
comparison
equal
deleted
inserted
replaced
293:ab618c2bbce8 | 294:94c636f8f863 |
---|---|
15 | 15 |
16 from pytouhou.game.sprite import Sprite | 16 from pytouhou.game.sprite import Sprite |
17 from pytouhou.vm.anmrunner import ANMRunner | 17 from pytouhou.vm.anmrunner import ANMRunner |
18 from pytouhou.game.bullettype import BulletType | 18 from pytouhou.game.bullettype import BulletType |
19 from pytouhou.game.bullet import Bullet | 19 from pytouhou.game.bullet import Bullet |
20 from pytouhou.game.lasertype import LaserType | |
21 from pytouhou.game.laser import PlayerLaser | |
20 | 22 |
21 from math import pi | 23 from math import pi |
22 | 24 |
23 | 25 |
24 class PlayerState(object): | 26 class PlayerState(object): |
108 def fire(self): | 110 def fire(self): |
109 sht = self.focused_sht if self.state.focused else self.sht | 111 sht = self.focused_sht if self.state.focused else self.sht |
110 power = min(power for power in sht.shots if self.state.power < power) | 112 power = min(power for power in sht.shots if self.state.power < power) |
111 | 113 |
112 bullets = self._game.players_bullets | 114 bullets = self._game.players_bullets |
115 lasers = self._game.players_lasers | |
113 nb_bullets_max = self._game.nb_bullets_max | 116 nb_bullets_max = self._game.nb_bullets_max |
114 | 117 |
115 for shot in sht.shots[power]: | 118 for shot in sht.shots[power]: |
116 if shot.type == 3: # TODO: Lasers aren't implemented yet | 119 origin = self.orbs[shot.orb - 1] if shot.orb else self.state |
120 | |
121 if shot.type == 3: | |
122 if self.fire_time != 30: | |
123 continue | |
124 | |
125 number = shot.delay #TODO: number can do very surprising things, like removing any bullet creation from enemies with 3. For now, crash when not 0 or 1. | |
126 if lasers[number]: | |
127 continue | |
128 | |
129 laser_type = LaserType(self.anm_wrapper, shot.sprite % 256, 68) | |
130 lasers[number] = PlayerLaser(laser_type, 0, shot.hitbox, shot.damage, shot.angle, shot.speed, shot.interval, origin) | |
117 continue | 131 continue |
118 | 132 |
119 if (self.fire_time + shot.delay) % shot.interval != 0: | 133 if (self.fire_time + shot.delay) % shot.interval != 0: |
120 continue | 134 continue |
121 | 135 |
122 if nb_bullets_max is not None and len(bullets) == nb_bullets_max: | 136 if nb_bullets_max is not None and len(bullets) == nb_bullets_max: |
123 break | 137 break |
124 | 138 |
125 origin = self.orbs[shot.orb - 1] if shot.orb else self | |
126 x = origin.x + shot.pos[0] | 139 x = origin.x + shot.pos[0] |
127 y = origin.y + shot.pos[1] | 140 y = origin.y + shot.pos[1] |
128 | 141 |
129 #TODO: find a better way to do that. | 142 #TODO: find a better way to do that. |
130 bullet_type = BulletType(self.anm_wrapper, shot.sprite % 256, | 143 bullet_type = BulletType(self.anm_wrapper, shot.sprite % 256, |
131 shot.sprite % 256 + 32, #TODO: find the real cancel anim | 144 shot.sprite % 256 + 32, #TODO: find the real cancel anim |
132 0, 0, 0, 0.) | 145 0, 0, 0, 0.) |
133 #TODO: Type 1 (homing bullets) and type 3 (laser) | 146 #TODO: Type 1 (homing bullets) |
134 if shot.type == 2: | 147 if shot.type == 2: |
135 #TODO: triple-check acceleration! | 148 #TODO: triple-check acceleration! |
136 bullets.append(Bullet((x, y), bullet_type, 0, | 149 bullets.append(Bullet((x, y), bullet_type, 0, |
137 shot.angle, shot.speed, | 150 shot.angle, shot.speed, |
138 (-1, 0, 0, 0, 0.15, -pi/2., 0., 0.), | 151 (-1, 0, 0, 0, 0.15, -pi/2., 0., 0.), |