Mercurial > touhou
comparison pytouhou/game/effect.py @ 193:9f58e2a6e950
Fix particles, fix "random" item popping, change update order to match the original game's more closely.
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Fri, 28 Oct 2011 12:38:26 +0200 |
parents | dbe6b7b2d3fc |
children | f3099ebf4f61 |
comparison
equal
deleted
inserted
replaced
192:5e84dfd153ab | 193:9f58e2a6e950 |
---|---|
38 if self._sprite._removed: | 38 if self._sprite._removed: |
39 self._sprite = None | 39 self._sprite = None |
40 | 40 |
41 | 41 |
42 class Particle(object): | 42 class Particle(object): |
43 def __init__(self, start_pos, index, anm_wrapper, size, amp, delay, game): | 43 def __init__(self, start_pos, index, anm_wrapper, size, amp, game): |
44 self._sprite = Sprite() | 44 self._sprite = Sprite() |
45 self._sprite.anm, self._sprite.texcoords = anm_wrapper.get_sprite(index) | 45 self._sprite.anm, self._sprite.texcoords = anm_wrapper.get_sprite(index) |
46 self._game = game | 46 self._game = game |
47 self._removed = False | 47 self._removed = False |
48 | 48 |
54 | 54 |
55 self.pos_interpolator = None | 55 self.pos_interpolator = None |
56 self.scale_interpolator = None | 56 self.scale_interpolator = None |
57 self.rotations_interpolator = None | 57 self.rotations_interpolator = None |
58 | 58 |
59 self.delay = delay | |
60 self.amp = amp | 59 self.amp = amp |
61 | 60 |
62 | 61 |
63 def set_end_pos(self, amp): | 62 def set_end_pos(self, amp): |
64 end_pos = (self.x + amp * self._game.prng.rand_double() - amp/2, | 63 end_pos = (self.x + amp * self._game.prng.rand_double() - amp/2, |
71 self.rotations_interpolator = Interpolator(self._sprite.rotations_3d, 0, | 70 self.rotations_interpolator = Interpolator(self._sprite.rotations_3d, 0, |
72 (0., 0., 2*pi), 24) | 71 (0., 0., 2*pi), 24) |
73 | 72 |
74 | 73 |
75 def update(self): | 74 def update(self): |
76 if (self.frame == 0 and not self.delay) or (self.frame == 1 and self.delay): | 75 if self.frame == 0: |
77 self.set_end_pos(self.amp) | 76 self.set_end_pos(self.amp) |
78 | 77 |
79 if self.pos_interpolator: | 78 if self.pos_interpolator: |
80 self.pos_interpolator.update(self.frame) | 79 self.pos_interpolator.update(self.frame) |
81 self.x, self.y = self.pos_interpolator.values | 80 self.x, self.y = self.pos_interpolator.values |