comparison pytouhou/game/game.py @ 196:1e501e3b6645

Add a subclass for each character, and implement player attacks.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sat, 29 Oct 2011 14:21:42 -0700
parents 9f58e2a6e950
children e1bc8c4cbb1a
comparison
equal deleted inserted replaced
195:52c0b9399413 196:1e501e3b6645
24 from pytouhou.game.effect import Particle 24 from pytouhou.game.effect import Particle
25 25
26 26
27 27
28 class Game(object): 28 class Game(object):
29 def __init__(self, resource_loader, player_states, stage, rank, difficulty, 29 def __init__(self, resource_loader, players, stage, rank, difficulty,
30 bullet_types, item_types, characters, prng=None, nb_bullets_max=None): 30 bullet_types, item_types, prng=None, nb_bullets_max=None):
31 self.resource_loader = resource_loader 31 self.resource_loader = resource_loader
32 32
33 self.nb_bullets_max = nb_bullets_max 33 self.nb_bullets_max = nb_bullets_max
34 self.bullet_types = bullet_types 34 self.bullet_types = bullet_types
35 self.item_types = item_types 35 self.item_types = item_types
36 self.characters = characters 36
37 37 self.players = players
38 self.players = [Player(player_state, characters[player_state.character], self) for player_state in player_states]
39 self.enemies = [] 38 self.enemies = []
40 self.effects = [] 39 self.effects = []
41 self.bullets = [] 40 self.bullets = []
42 self.cancelled_bullets = [] 41 self.cancelled_bullets = []
43 self.players_bullets = [] 42 self.players_bullets = []
142 141
143 if not (bx2 < ex1 or bx1 > ex2 142 if not (bx2 < ex1 or bx1 > ex2
144 or by2 < ey1 or by1 > ey2): 143 or by2 < ey1 or by1 > ey2):
145 bullet.collide() 144 bullet.collide()
146 enemy.on_attack(bullet) 145 enemy.on_attack(bullet)
147 player.state.score += 90 # found experimentally 146 #TODO: place that at the right place.
147 #player.state.score += 90 # found experimentally
148 148
149 149
150 def update_players(self, keystate): 150 def update_players(self, keystate):
151 for player in self.players: 151 for player in self.players:
152 player.update(keystate) #TODO: differentiate keystates (multiplayer mode) 152 player.update(keystate) #TODO: differentiate keystates (multiplayer mode)