Mercurial > touhou
comparison pytouhou/game/game.pyx @ 509:292fea5c584e
Some more type optimisations.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Mon, 25 Nov 2013 19:12:56 +0100 |
parents | 3d3285918ba1 |
children | 577c3a88fb67 |
comparison
equal
deleted
inserted
replaced
508:1bc014f9d572 | 509:292fea5c584e |
---|---|
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, |
28 laser_types, item_types, long nb_bullets_max=0, long width=384, | 28 laser_types, item_types, long nb_bullets_max=0, long width=384, |
29 long height=448, prng=None, interface=None, hints=None, | 29 long height=448, Random prng=None, interface=None, hints=None, |
30 friendly_fire=True): | 30 bint friendly_fire=True): |
31 self.width, self.height = width, height | 31 self.width, self.height = width, height |
32 | 32 |
33 self.nb_bullets_max = nb_bullets_max | 33 self.nb_bullets_max = nb_bullets_max |
34 self.bullet_types = bullet_types | 34 self.bullet_types = bullet_types |
35 self.laser_types = laser_types | 35 self.laser_types = laser_types |
83 | 83 |
84 cdef list lasers_sprites(self): | 84 cdef list lasers_sprites(self): |
85 return [laser for laser in self.players_lasers if laser is not None] | 85 return [laser for laser in self.players_lasers if laser is not None] |
86 | 86 |
87 | 87 |
88 cdef void modify_difficulty(self, long diff): | 88 cdef void modify_difficulty(self, long diff) nogil: |
89 self.difficulty_counter += diff | 89 self.difficulty_counter += diff |
90 while self.difficulty_counter < 0: | 90 while self.difficulty_counter < 0: |
91 self.difficulty -= 1 | 91 self.difficulty -= 1 |
92 self.difficulty_counter += 100 | 92 self.difficulty_counter += 100 |
93 while self.difficulty_counter >= 100: | 93 while self.difficulty_counter >= 100: |
267 return face | 267 return face |
268 | 268 |
269 | 269 |
270 cpdef run_iter(self, list keystates): | 270 cpdef run_iter(self, list keystates): |
271 cdef Laser laser | 271 cdef Laser laser |
272 cdef long i | |
272 | 273 |
273 # 1. VMs. | 274 # 1. VMs. |
274 for runner in self.ecl_runners: | 275 for runner in self.ecl_runners: |
275 runner.run_iter() | 276 runner.run_iter() |
276 | 277 |