comparison pytouhou/game/game.pyx @ 590:e15672733c93

Switch to Python 3.x instead of 2.7.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Tue, 30 Sep 2014 17:14:24 +0200
parents 94229756abd9
children 3c2f96f1d715
comparison
equal deleted inserted replaced
589:0768122da817 590:e15672733c93
188 cdef Bullet bullet 188 cdef Bullet bullet
189 189
190 score = 0 190 score = 0
191 bonus = 2000 191 bonus = 2000
192 for bullet in self.bullets: 192 for bullet in self.bullets:
193 self.new_label((bullet.x, bullet.y), str(bonus)) 193 self.new_label((bullet.x, bullet.y), str(bonus).encode())
194 score += bonus 194 score += bonus
195 bonus += 10 195 bonus += 10
196 self.bullets = [] 196 self.bullets = []
197 #TODO: display the final bonus score. 197 #TODO: display the final bonus score.
198 198
214 enemy.death_callback.fire() 214 enemy.death_callback.fire()
215 215
216 216
217 cpdef new_effect(self, pos, long anim, anm=None, long number=1): 217 cpdef new_effect(self, pos, long anim, anm=None, long number=1):
218 number = min(number, self.nb_bullets_max - len(self.effects)) 218 number = min(number, self.nb_bullets_max - len(self.effects))
219 for i in xrange(number): 219 for i in range(number):
220 self.effects.append(Effect(pos, anim, anm or self.etama[1])) 220 self.effects.append(Effect(pos, anim, anm or self.etama[1]))
221 221
222 222
223 cpdef new_particle(self, pos, long anim, long amp, long number=1, bint reverse=False, long duration=24): 223 cpdef new_particle(self, pos, long anim, long amp, long number=1, bint reverse=False, long duration=24):
224 number = min(number, self.nb_bullets_max - len(self.effects)) 224 number = min(number, self.nb_bullets_max - len(self.effects))
225 for i in xrange(number): 225 for i in range(number):
226 self.effects.append(Particle(pos, anim, self.etama[1], amp, self, reverse=reverse, duration=duration)) 226 self.effects.append(Particle(pos, anim, self.etama[1], amp, self, reverse=reverse, duration=duration))
227 227
228 228
229 cpdef new_enemy(self, pos, life, instr_type, bonus_dropped, die_score): 229 cpdef new_enemy(self, pos, life, instr_type, bonus_dropped, die_score):
230 enemy = Enemy(pos, life, instr_type, bonus_dropped, die_score, self.enm_anm, self) 230 enemy = Enemy(pos, life, instr_type, bonus_dropped, die_score, self.enm_anm, self)
293 293
294 # Pri 6 is background 294 # Pri 6 is background
295 self.update_background() #TODO: Pri unknown 295 self.update_background() #TODO: Pri unknown
296 if self.msg_runner is not None: 296 if self.msg_runner is not None:
297 self.update_msg(keystates[0]) # Pri ? 297 self.update_msg(keystates[0]) # Pri ?
298 for i in xrange(len(keystates)): 298 for i in range(len(keystates)):
299 keystates[i] &= ~3 # Remove the ability to attack (keystates 1 and 2). 299 keystates[i] &= ~3 # Remove the ability to attack (keystates 1 and 2).
300 self.update_players(keystates) # Pri 7 300 self.update_players(keystates) # Pri 7
301 self.update_enemies() # Pri 9 301 self.update_enemies() # Pri 9
302 self.update_effects() # Pri 10 302 self.update_effects() # Pri 10
303 self.update_bullets() # Pri 11 303 self.update_bullets() # Pri 11
306 self.interface.update() # Pri 12 306 self.interface.update() # Pri 12
307 if self.hints: 307 if self.hints:
308 self.update_hints() # Not from this game, so unknown. 308 self.update_hints() # Not from this game, so unknown.
309 for label in self.labels: #TODO: what priority is it? 309 for label in self.labels: #TODO: what priority is it?
310 label.update() 310 label.update()
311 for text in self.texts.itervalues(): #TODO: what priority is it? 311 for text in self.texts.values(): #TODO: what priority is it?
312 if text is not None: 312 if text is not None:
313 text.update() 313 text.update()
314 self.update_faces() # Pri XXX 314 self.update_faces() # Pri XXX
315 315
316 # 5. Clean up 316 # 5. Clean up
578 self.modify_difficulty(-3) 578 self.modify_difficulty(-3)
579 self.items = items 579 self.items = items
580 580
581 self.effects = filter_removed(self.effects) 581 self.effects = filter_removed(self.effects)
582 self.labels = filter_removed(self.labels) 582 self.labels = filter_removed(self.labels)
583 583 self.texts = {key: text for key, text in self.texts.items() if not text.removed}
584 for key, text in self.texts.items():
585 if text.removed:
586 del self.texts[key]
587 584
588 # Disable boss mode if it is dead/it has timeout 585 # Disable boss mode if it is dead/it has timeout
589 if self.boss and self.boss.removed: 586 if self.boss and self.boss.removed:
590 self.boss = None 587 self.boss = None
591 588