comparison pytouhou/game/game.py @ 300:da53bc29b94a

Add the game interface.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sat, 10 Mar 2012 17:47:03 +0100
parents e04e402e6380
children 647bde10353d
comparison
equal deleted inserted replaced
299:e04e402e6380 300:da53bc29b94a
27 27
28 28
29 class Game(object): 29 class Game(object):
30 def __init__(self, resource_loader, players, stage, rank, difficulty, 30 def __init__(self, resource_loader, players, stage, rank, difficulty,
31 bullet_types, laser_types, item_types, 31 bullet_types, laser_types, item_types,
32 nb_bullets_max=None, width=384, height=448, prng=None): 32 nb_bullets_max=None, width=384, height=448, prng=None, interface=None):
33 self.resource_loader = resource_loader 33 self.resource_loader = resource_loader
34 34
35 self.width, self.height = width, height 35 self.width, self.height = width, height
36 36
37 self.nb_bullets_max = nb_bullets_max 37 self.nb_bullets_max = nb_bullets_max
46 self.lasers = [] 46 self.lasers = []
47 self.cancelled_bullets = [] 47 self.cancelled_bullets = []
48 self.players_bullets = [] 48 self.players_bullets = []
49 self.players_lasers = [None, None] 49 self.players_lasers = [None, None]
50 self.items = [] 50 self.items = []
51 self.interface = interface
51 52
52 self.stage = stage 53 self.stage = stage
53 self.rank = rank 54 self.rank = rank
54 self.difficulty = difficulty 55 self.difficulty = difficulty
55 self.difficulty_counter = 0 56 self.difficulty_counter = 0
185 self.update_enemies() # Pri 9 186 self.update_enemies() # Pri 9
186 self.update_effects() # Pri 10 187 self.update_effects() # Pri 10
187 self.update_bullets() # Pri 11 188 self.update_bullets() # Pri 11
188 for laser in self.lasers: #TODO: what priority is it? 189 for laser in self.lasers: #TODO: what priority is it?
189 laser.update() 190 laser.update()
190 # Pri 12 is HUD 191 self.interface.update() # Pri 12
191 192
192 # 4. Cleaning 193 # 4. Cleaning
193 self.cleanup() 194 self.cleanup()
194 195
195 self.frame += 1 196 self.frame += 1
342 self.lasers = [laser for laser in self.lasers if not laser._removed] 343 self.lasers = [laser for laser in self.lasers if not laser._removed]
343 344
344 # Filter out-of-scren items 345 # Filter out-of-scren items
345 items = [] 346 items = []
346 for item in self.items: 347 for item in self.items:
347 if item.y < 448: 348 if item.y < self.height:
348 items.append(item) 349 items.append(item)
349 else: 350 else:
350 self.modify_difficulty(-3) 351 self.modify_difficulty(-3)
351 self.items = items 352 self.items = items
352 353