comparison pytouhou/game/game.py @ 190:dbe6b7b2d3fc

Fix a few things about particles.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Thu, 27 Oct 2011 15:09:42 -0700
parents 008f90ebfdc0
children 5e84dfd153ab
comparison
equal deleted inserted replaced
189:ba3297ab3bde 190:dbe6b7b2d3fc
82 def new_death(self, pos, index): 82 def new_death(self, pos, index):
83 anim = {0: 3, 1: 4, 2: 5}[index % 256] # The TB is wanted, if index isn’t in these values the original game crashs. 83 anim = {0: 3, 1: 4, 2: 5}[index % 256] # The TB is wanted, if index isn’t in these values the original game crashs.
84 self.effects.append(Effect(pos, anim, self.etama4)) 84 self.effects.append(Effect(pos, anim, self.etama4))
85 85
86 86
87 def new_particle(self, pos, color, size, amp): 87 def new_particle(self, pos, color, size, amp, delay=False):
88 self.effects.append(Particle(pos, 7 + 4 * color + self.prng.rand_uint16() % 4, self.etama4, size, 88 self.effects.append(Particle(pos, 7 + 4 * color + self.prng.rand_uint16() % 4, self.etama4, size, amp, delay, self))
89 (pos[0] + amp * self.prng.rand_double() - amp/2,
90 pos[1] + amp * self.prng.rand_double() - amp/2)))
91 89
92 90
93 def new_enemy(self, pos, life, instr_type, bonus_dropped, die_score): 91 def new_enemy(self, pos, life, instr_type, bonus_dropped, die_score):
94 enemy = Enemy(pos, life, instr_type, bonus_dropped, die_score, self.enm_anm_wrapper, self) 92 enemy = Enemy(pos, life, instr_type, bonus_dropped, die_score, self.enm_anm_wrapper, self)
95 self.enemies.append(enemy) 93 self.enemies.append(enemy)
168 elif not bullet.grazed and not (bx2 < gx1 or bx1 > gx2 166 elif not bullet.grazed and not (bx2 < gx1 or bx1 > gx2
169 or by2 < gy1 or by1 > gy2): 167 or by2 < gy1 or by1 > gy2):
170 bullet.grazed = True 168 bullet.grazed = True
171 player.state.graze += 1 169 player.state.graze += 1
172 player.state.score += 500 # found experimentally 170 player.state.score += 500 # found experimentally
173 self.new_particle((px, py), 0, .8, 192) #TODO: find the real size and range. 171 self.new_particle((px, py), 0, .8, 192, delay=True) #TODO: find the real size and range.
174 #TODO: display a static particle during one frame at 172 #TODO: display a static particle during one frame at
175 # 12 pixels of the player, in the axis of the “collision”. 173 # 12 pixels of the player, in the axis of the “collision”.
176 174
177 for enemy in self.enemies: 175 for enemy in self.enemies:
178 half_size_x, half_size_y = enemy.hitbox_half_size 176 half_size_x, half_size_y = enemy.hitbox_half_size