comparison pytouhou/game/game.pyx @ 516:577c3a88fb67

Merge the lists Game.texts and Game.native_texts into the Game.texts dict.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sun, 11 May 2014 20:25:07 +0200
parents 292fea5c584e
children bcff39c920ab
comparison
equal deleted inserted replaced
515:b3193b43a86c 516:577c3a88fb67
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, None, None] 49 self.texts = {}
50 self.interface = interface 50 self.interface = interface
51 self.hints = hints 51 self.hints = hints
52 52
53 self.stage = stage 53 self.stage = stage
54 self.rank = rank 54 self.rank = rank
108 face = Effect(pos, 3, self.msg_anm[0][0][0]) 108 face = Effect(pos, 3, self.msg_anm[0][0][0])
109 face.sprite.allow_dest_offset = True 109 face.sprite.allow_dest_offset = True
110 face.sprite.anm, face.sprite.texcoords = self.msg_anm[1][self.spellcard[2]] 110 face.sprite.anm, face.sprite.texcoords = self.msg_anm[1][self.spellcard[2]]
111 self.effects.append(face) 111 self.effects.append(face)
112 112
113 self.texts[5] = self.new_native_text((384-24, 24), self.spellcard[1], align='right') 113 self.texts['enemy_spellcard'] = self.new_native_text((384-24, 24), self.spellcard[1], align='right')
114 114
115 115
116 cpdef disable_spellcard_effect(self): 116 cpdef disable_spellcard_effect(self):
117 self.spellcard_effect = None 117 self.spellcard_effect = None
118 self.texts[5] = None 118 if 'enemy_spellcard' in self.texts:
119 del self.texts['enemy_spellcard']
119 120
120 121
121 cdef void set_player_bomb(self): 122 cdef void set_player_bomb(self):
122 face = Effect((-32, -16), 1, self.msg_anm[0][0][0]) 123 face = Effect((-32, -16), 1, self.msg_anm[0][0][0])
123 face.sprite.allow_dest_offset = True 124 face.sprite.allow_dest_offset = True
124 self.effects.append(face) 125 self.effects.append(face)
125 self.texts[4] = self.new_native_text((24, 24), u'Player Spellcard') 126 self.texts['player_spellcard'] = self.new_native_text((24, 24), u'Player Spellcard')
126 127
127 128
128 cdef void unset_player_bomb(self): 129 cdef void unset_player_bomb(self):
129 self.texts[4] = None 130 del self.texts['player_spellcard']
130 131
131 132
132 cpdef drop_bonus(self, double x, double y, long _type, end_pos=None, player=None): 133 cpdef drop_bonus(self, double x, double y, long _type, end_pos=None, player=None):
133 if _type > 6: 134 if _type > 6:
134 return 135 return
305 self.interface.update() # Pri 12 306 self.interface.update() # Pri 12
306 if self.hints: 307 if self.hints:
307 self.update_hints() # Not from this game, so unknown. 308 self.update_hints() # Not from this game, so unknown.
308 for label in self.labels: #TODO: what priority is it? 309 for label in self.labels: #TODO: what priority is it?
309 label.update() 310 label.update()
310 for text in self.texts: #TODO: what priority is it? 311 for text in self.texts.itervalues(): #TODO: what priority is it?
311 if text is not None:
312 text.update()
313 for text in self.native_texts: #TODO: what priority is it?
314 if text is not None: 312 if text is not None:
315 text.update() 313 text.update()
316 self.update_faces() # Pri XXX 314 self.update_faces() # Pri XXX
317 315
318 # 5. Clean up 316 # 5. Clean up
573 self.modify_difficulty(-3) 571 self.modify_difficulty(-3)
574 self.items = items 572 self.items = items
575 573
576 self.effects = filter_removed(self.effects) 574 self.effects = filter_removed(self.effects)
577 self.labels = filter_removed(self.labels) 575 self.labels = filter_removed(self.labels)
578 #self.native_texts = filter_removed(self.native_texts) 576
579 577 for key, text in self.texts.items():
580 for i, text in enumerate(self.texts): 578 if text.removed:
581 if text is not None and text.removed: 579 del self.texts[key]
582 self.texts[i] = None
583 580
584 # Disable boss mode if it is dead/it has timeout 581 # Disable boss mode if it is dead/it has timeout
585 if self.boss and self.boss._enemy.removed: 582 if self.boss and self.boss._enemy.removed:
586 self.boss = None 583 self.boss = None
587 584