Mercurial > touhou
comparison pytouhou/game/game.py @ 403:9589a01e6edf
Move MSG faces management to pytouhou.game.game, they have nothing to do in the MSG VM.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sun, 17 Feb 2013 15:20:30 +0100 |
parents | b11953cf1d3b |
children | 6c0cb3eee33e |
comparison
equal
deleted
inserted
replaced
402:88e2a2485b2b | 403:9589a01e6edf |
---|---|
20 from pytouhou.game.bullet import LAUNCHED, CANCELLED | 20 from pytouhou.game.bullet import LAUNCHED, CANCELLED |
21 from pytouhou.game.enemy import Enemy | 21 from pytouhou.game.enemy import Enemy |
22 from pytouhou.game.item import Item | 22 from pytouhou.game.item import Item |
23 from pytouhou.game.effect import Effect, Particle | 23 from pytouhou.game.effect import Effect, Particle |
24 from pytouhou.game.text import Text | 24 from pytouhou.game.text import Text |
25 from pytouhou.game.face import Face | |
25 | 26 |
26 | 27 |
27 | 28 |
28 class GameOver(Exception): | 29 class GameOver(Exception): |
29 pass | 30 pass |
51 self.cancelled_bullets = [] | 52 self.cancelled_bullets = [] |
52 self.players_bullets = [] | 53 self.players_bullets = [] |
53 self.players_lasers = [None, None] | 54 self.players_lasers = [None, None] |
54 self.items = [] | 55 self.items = [] |
55 self.labels = [] | 56 self.labels = [] |
57 self.faces = [None, None] | |
56 self.interface = interface | 58 self.interface = interface |
57 | 59 |
58 self.continues = continues | 60 self.continues = continues |
59 self.stage = stage | 61 self.stage = stage |
60 self.rank = rank | 62 self.rank = rank |
90 | 92 |
91 self.last_keystate = 0 | 93 self.last_keystate = 0 |
92 | 94 |
93 | 95 |
94 def msg_sprites(self): | 96 def msg_sprites(self): |
95 return [] | 97 return [face for face in self.faces if face] if self.msg_runner and not self.msg_runner.ended else [] |
96 | 98 |
97 | 99 |
98 def lasers_sprites(self): | 100 def lasers_sprites(self): |
99 return [laser for laser in self.players_lasers if laser] | 101 return [laser for laser in self.players_lasers if laser] |
100 | 102 |
210 def new_label(self, pos, text): | 212 def new_label(self, pos, text): |
211 label = Text(pos, self.ascii_wrapper, text=text, xspacing=8, shift=48) | 213 label = Text(pos, self.ascii_wrapper, text=text, xspacing=8, shift=48) |
212 label.set_timeout(60) | 214 label.set_timeout(60) |
213 self.labels.append(label) | 215 self.labels.append(label) |
214 return label | 216 return label |
217 | |
218 | |
219 def new_face(self, side, effect): | |
220 face = Face(self.msg_anm_wrapper, effect, side) | |
221 self.faces[side] = face | |
222 return face | |
215 | 223 |
216 | 224 |
217 def run_iter(self, keystate): | 225 def run_iter(self, keystate): |
218 # 1. VMs. | 226 # 1. VMs. |
219 for runner in self.ecl_runners: | 227 for runner in self.ecl_runners: |
247 for laser in self.lasers: #TODO: what priority is it? | 255 for laser in self.lasers: #TODO: what priority is it? |
248 laser.update() | 256 laser.update() |
249 self.interface.update() # Pri 12 | 257 self.interface.update() # Pri 12 |
250 for label in self.labels: #TODO: what priority is it? | 258 for label in self.labels: #TODO: what priority is it? |
251 label.update() | 259 label.update() |
260 self.update_faces() # Pri XXX | |
252 | 261 |
253 # 5. Clean up | 262 # 5. Clean up |
254 self.cleanup() | 263 self.cleanup() |
255 | 264 |
256 self.frame += 1 | 265 self.frame += 1 |
294 | 303 |
295 | 304 |
296 def update_effects(self): | 305 def update_effects(self): |
297 for effect in self.effects: | 306 for effect in self.effects: |
298 effect.update() | 307 effect.update() |
308 | |
309 | |
310 def update_faces(self): | |
311 for face in self.faces: | |
312 if face: | |
313 face.update() | |
299 | 314 |
300 | 315 |
301 def update_bullets(self): | 316 def update_bullets(self): |
302 if self.time_stop: | 317 if self.time_stop: |
303 return None | 318 return None |