Mercurial > touhou
comparison pytouhou/game/game.pyx @ 456:cae1ae9de430
Add native text support, MSG instructions 3 and 8, and text at the beginning of a stage.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Tue, 16 Jul 2013 21:11:40 +0200 |
parents | 3bc37791f0a2 |
children | 4ccc47828002 |
comparison
equal
deleted
inserted
replaced
455:6864a38b2413 | 456:cae1ae9de430 |
---|---|
17 from pytouhou.game.element cimport Element | 17 from pytouhou.game.element cimport Element |
18 from pytouhou.game.bullet cimport Bullet, LAUNCHED, CANCELLED | 18 from pytouhou.game.bullet cimport Bullet, LAUNCHED, CANCELLED |
19 from pytouhou.game.enemy cimport Enemy | 19 from pytouhou.game.enemy cimport Enemy |
20 from pytouhou.game.item cimport Item | 20 from pytouhou.game.item cimport Item |
21 from pytouhou.game.effect cimport Particle | 21 from pytouhou.game.effect cimport Particle |
22 from pytouhou.game.text import Text | 22 from pytouhou.game.text import Text, NativeText |
23 from pytouhou.game.face import Face | 23 from pytouhou.game.face import Face |
24 | 24 |
25 | 25 |
26 cdef class Game: | 26 cdef class Game: |
27 def __init__(self, players, long stage, long rank, long difficulty, bullet_types, | 27 def __init__(self, players, long stage, long rank, long difficulty, bullet_types, |
44 self.players_bullets = [] | 44 self.players_bullets = [] |
45 self.players_lasers = [None, None] | 45 self.players_lasers = [None, None] |
46 self.items = [] | 46 self.items = [] |
47 self.labels = [] | 47 self.labels = [] |
48 self.faces = [None, None] | 48 self.faces = [None, None] |
49 self.texts = [None, None, None, None] | |
49 self.interface = interface | 50 self.interface = interface |
50 self.hints = hints | 51 self.hints = hints |
51 | 52 |
52 self.continues = continues | 53 self.continues = continues |
53 self.stage = stage | 54 self.stage = stage |
207 label.set_timeout(60, effect='move') | 208 label.set_timeout(60, effect='move') |
208 self.labels.append(label) | 209 self.labels.append(label) |
209 return label | 210 return label |
210 | 211 |
211 | 212 |
213 def new_native_text(self, pos, text, align='left'): | |
214 label = NativeText(pos, text, shadow=True, align=align) | |
215 return label | |
216 | |
217 | |
212 def new_hint(self, hint): | 218 def new_hint(self, hint): |
213 pos = hint['Pos'] | 219 pos = hint['Pos'] |
214 #TODO: Scale | 220 #TODO: Scale |
215 | 221 |
216 pos = pos[0] + 192, pos[1] | 222 pos = pos[0] + 192, pos[1] |
262 self.interface.update() # Pri 12 | 268 self.interface.update() # Pri 12 |
263 if self.hints: | 269 if self.hints: |
264 self.update_hints() # Not from this game, so unknown. | 270 self.update_hints() # Not from this game, so unknown. |
265 for label in self.labels: #TODO: what priority is it? | 271 for label in self.labels: #TODO: what priority is it? |
266 label.update() | 272 label.update() |
273 for text in self.texts: #TODO: what priority is it? | |
274 if text is not None: | |
275 text.update() | |
276 for text in self.native_texts: #TODO: what priority is it? | |
277 if text is not None: | |
278 text.update() | |
267 self.update_faces() # Pri XXX | 279 self.update_faces() # Pri XXX |
268 | 280 |
269 # 5. Clean up | 281 # 5. Clean up |
270 self.cleanup() | 282 self.cleanup() |
271 | 283 |
485 self.modify_difficulty(-3) | 497 self.modify_difficulty(-3) |
486 self.items = items | 498 self.items = items |
487 | 499 |
488 self.effects = filter_removed(self.effects) | 500 self.effects = filter_removed(self.effects) |
489 self.labels = filter_removed(self.labels) | 501 self.labels = filter_removed(self.labels) |
502 #self.native_texts = filter_removed(self.native_texts) | |
503 | |
504 for i, text in enumerate(self.texts): | |
505 if text is not None and text.removed: | |
506 self.texts[i] = None | |
490 | 507 |
491 # Disable boss mode if it is dead/it has timeout | 508 # Disable boss mode if it is dead/it has timeout |
492 if self.boss and self.boss._enemy.removed: | 509 if self.boss and self.boss._enemy.removed: |
493 self.boss = None | 510 self.boss = None |
494 | 511 |