comparison pytouhou/game/player.py @ 430:c9433188ffdb

Remove AnmWrapper, since ANMs are lists of entries now.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sat, 03 Aug 2013 15:49:04 +0200
parents b11953cf1d3b
children 1222341ea22c
comparison
equal deleted inserted replaced
429:40d5f3083ebc 430:c9433188ffdb
51 return PlayerState(self.character, self.score, 51 return PlayerState(self.character, self.score,
52 self.power, self.lives, self.bombs) 52 self.power, self.lives, self.bombs)
53 53
54 54
55 class Player(object): 55 class Player(object):
56 def __init__(self, state, game, anm_wrapper): 56 def __init__(self, state, game, anm):
57 self._game = game 57 self._game = game
58 self.sprite = None 58 self.sprite = None
59 self.anmrunner = None 59 self.anmrunner = None
60 self.anm_wrapper = anm_wrapper 60 self.anm = anm
61 61
62 self.speeds = (self.sht.horizontal_vertical_speed, 62 self.speeds = (self.sht.horizontal_vertical_speed,
63 self.sht.diagonal_speed, 63 self.sht.diagonal_speed,
64 self.sht.horizontal_vertical_focused_speed, 64 self.sht.horizontal_vertical_focused_speed,
65 self.sht.diagonal_focused_speed) 65 self.sht.diagonal_focused_speed)
84 return self.state.y 84 return self.state.y
85 85
86 86
87 def set_anim(self, index): 87 def set_anim(self, index):
88 self.sprite = Sprite() 88 self.sprite = Sprite()
89 self.anmrunner = ANMRunner(self.anm_wrapper, index, self.sprite) 89 self.anmrunner = ANMRunner(self.anm, index, self.sprite)
90 self.anmrunner.run_frame() 90 self.anmrunner.run_frame()
91 91
92 92
93 def play_sound(self, name): 93 def play_sound(self, name):
94 self._game.sfx_player.play('%s.wav' % name) 94 self._game.sfx_player.play('%s.wav' % name)
132 132
133 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. 133 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.
134 if lasers[number]: 134 if lasers[number]:
135 continue 135 continue
136 136
137 laser_type = LaserType(self.anm_wrapper, shot.sprite % 256, 68) 137 laser_type = LaserType(self.anm, shot.sprite % 256, 68)
138 lasers[number] = PlayerLaser(laser_type, 0, shot.hitbox, shot.damage, shot.angle, shot.speed, shot.interval, origin) 138 lasers[number] = PlayerLaser(laser_type, 0, shot.hitbox, shot.damage, shot.angle, shot.speed, shot.interval, origin)
139 continue 139 continue
140 140
141 if (self.fire_time + shot.delay) % shot.interval != 0: 141 if (self.fire_time + shot.delay) % shot.interval != 0:
142 continue 142 continue
146 146
147 x = origin.x + shot.pos[0] 147 x = origin.x + shot.pos[0]
148 y = origin.y + shot.pos[1] 148 y = origin.y + shot.pos[1]
149 149
150 #TODO: find a better way to do that. 150 #TODO: find a better way to do that.
151 bullet_type = BulletType(self.anm_wrapper, shot.sprite % 256, 151 bullet_type = BulletType(self.anm, shot.sprite % 256,
152 shot.sprite % 256 + 32, #TODO: find the real cancel anim 152 shot.sprite % 256 + 32, #TODO: find the real cancel anim
153 0, 0, 0, 0.) 153 0, 0, 0, 0.)
154 #TODO: Type 1 (homing bullets) 154 #TODO: Type 1 (homing bullets)
155 if shot.type == 2: 155 if shot.type == 2:
156 #TODO: triple-check acceleration! 156 #TODO: triple-check acceleration!
272 self.state.x = float(self._game.width) / 2. #TODO 272 self.state.x = float(self._game.width) / 2. #TODO
273 self.state.y = float(self._game.width) #TODO 273 self.state.y = float(self._game.width) #TODO
274 self.direction = None 274 self.direction = None
275 275
276 self.sprite = Sprite() 276 self.sprite = Sprite()
277 self.anmrunner = ANMRunner(self.anm_wrapper, 0, self.sprite) 277 self.anmrunner = ANMRunner(self.anm, 0, self.sprite)
278 self.sprite.alpha = 128 278 self.sprite.alpha = 128
279 self.sprite.rescale = 0.0, 2.5 279 self.sprite.rescale = 0.0, 2.5
280 self.sprite.fade(30, 255, lambda x: x) 280 self.sprite.fade(30, 255, lambda x: x)
281 self.sprite.blendfunc = 1 281 self.sprite.blendfunc = 1
282 self.sprite.scale_in(30, 1., 1., lambda x: x) 282 self.sprite.scale_in(30, 1., 1., lambda x: x)