def _emit_tail(self, system): # create initial direction with random vector length and angle velocity = th.PolarVector2(th.random(30, 70), th.random(0, 360)) # create particle at position of explosion, with emitter-specific color # and at 80% initial scale particle = th.Particle(TAIL_DURATION) particle.position = self._position particle.color = self._color particle.scale = particle.scale * 0.8 # a tail contains 25 particles with different speeds and scales # the largest particles move fastest, leading to a comet-like tail effect for i in range(25): # decrease scale continuously particle.scale *= 0.95 # decrease speed continuously velocity.r = velocity.r * 0.96 #particle.velocity = velocity particle.velocity = velocity.to_vector2() # add adapted particle to particle system system.add_particle(particle)
def __init__(self, position): th.Emitter.__init__(self) self._accumulated_time = copy(sf.Time.ZERO) self._position = copy(position) self._color = copy(firework_colors[int(th.random(0, len(firework_colors)-1))])