Beispiel #1
0
    def explode_ringed_firework(self, prev_emitter):
        """Actions that happen when a firework shell explodes, resulting in a ringed firework"""
        self.emitters.append(make_puff(prev_emitter))
        self.emitters.append(make_flash(prev_emitter))

        spark_texture, ring_texture = random.choice(SPARK_PAIRS)
        sparks = arcadeplus.Emitter(
            center_xy=prev_emitter.get_pos(),
            emit_controller=arcadeplus.EmitBurst(25),
            particle_factory=lambda emitter: arcadeplus.FadeParticle(
                filename_or_texture=spark_texture,
                change_xy=arcadeplus.rand_in_circle((0.0, 0.0), 8.0),
                lifetime=random.uniform(0.55, 0.8),
                mutation_callback=firework_spark_mutator))
        self.emitters.append(sparks)

        ring = arcadeplus.Emitter(
            center_xy=prev_emitter.get_pos(),
            emit_controller=arcadeplus.EmitBurst(20),
            particle_factory=lambda emitter: arcadeplus.FadeParticle(
                filename_or_texture=ring_texture,
                change_xy=arcadeplus.rand_on_circle(
                    (0.0, 0.0), 5.0) + arcadeplus.rand_in_circle(
                        (0.0, 0.0), 0.25),
                lifetime=random.uniform(1.0, 1.6),
                mutation_callback=firework_spark_mutator))
        self.emitters.append(ring)
Beispiel #2
0
def emitter_27():
    """Maintain a steady count of particles"""
    e = arcadeplus.Emitter(
        center_xy=CENTER_POS,
        emit_controller=arcadeplus.EmitMaintainCount(3),
        particle_factory=lambda emitter: arcadeplus.LifetimeParticle(
            filename_or_texture=TEXTURE,
            change_xy=arcadeplus.rand_on_circle((0.0, 0.0), 2.0),
            lifetime=random.uniform(1.0, 3.0),
        ))
    return emitter_27.__doc__, e
Beispiel #3
0
def emitter_7():
    """Burst, emit from center, velocity fixed speed around 360 degrees"""
    e = arcadeplus.Emitter(
        center_xy=CENTER_POS,
        emit_controller=arcadeplus.EmitBurst(BURST_PARTICLE_COUNT // 4),
        particle_factory=lambda emitter: arcadeplus.LifetimeParticle(
            filename_or_texture=TEXTURE,
            change_xy=arcadeplus.rand_on_circle(
                (0.0, 0.0), PARTICLE_SPEED_FAST),
            lifetime=DEFAULT_PARTICLE_LIFETIME,
            scale=DEFAULT_SCALE,
            alpha=DEFAULT_ALPHA))
    return emitter_7.__doc__, e
Beispiel #4
0
def emitter_20():
    """Interval, emit from center, velocity fixed speed around 360 degrees"""
    e = arcadeplus.Emitter(
        center_xy=CENTER_POS,
        emit_controller=arcadeplus.EmitterIntervalWithTime(
            DEFAULT_EMIT_INTERVAL, DEFAULT_EMIT_DURATION),
        particle_factory=lambda emitter: arcadeplus.LifetimeParticle(
            filename_or_texture=TEXTURE,
            change_xy=arcadeplus.rand_on_circle(
                (0.0, 0.0), PARTICLE_SPEED_FAST),
            lifetime=DEFAULT_PARTICLE_LIFETIME,
            scale=DEFAULT_SCALE,
            alpha=DEFAULT_ALPHA))
    return emitter_20.__doc__, e
Beispiel #5
0
def emitter_4():
    """Burst, emit on circle"""
    e = arcadeplus.Emitter(
        center_xy=CENTER_POS,
        emit_controller=arcadeplus.EmitBurst(BURST_PARTICLE_COUNT),
        particle_factory=lambda emitter: arcadeplus.LifetimeParticle(
            filename_or_texture=TEXTURE,
            change_xy=arcadeplus.rand_in_circle(
                (0.0, 0.0), PARTICLE_SPEED_SLOW),
            lifetime=DEFAULT_PARTICLE_LIFETIME,
            center_xy=arcadeplus.rand_on_circle((0.0, 0.0), 100),
            scale=DEFAULT_SCALE,
            alpha=DEFAULT_ALPHA))
    return emitter_4.__doc__, e
Beispiel #6
0
def emitter_17():
    """Interval, emit on circle"""
    e = arcadeplus.Emitter(
        center_xy=CENTER_POS,
        emit_controller=arcadeplus.EmitterIntervalWithTime(
            DEFAULT_EMIT_INTERVAL, DEFAULT_EMIT_DURATION),
        particle_factory=lambda emitter: arcadeplus.LifetimeParticle(
            filename_or_texture=TEXTURE,
            change_xy=arcadeplus.rand_in_circle(
                (0.0, 0.0), PARTICLE_SPEED_SLOW),
            lifetime=DEFAULT_PARTICLE_LIFETIME,
            center_xy=arcadeplus.rand_on_circle((0.0, 0.0), 100),
            scale=DEFAULT_SCALE,
            alpha=DEFAULT_ALPHA))
    return emitter_17.__doc__, e
Beispiel #7
0
def make_interval_emitter(center_xy: Point,
                          filenames_and_textures: Sequence[FilenameOrTexture],
                          emit_interval: float,
                          emit_duration: float,
                          particle_speed: float,
                          particle_lifetime_min: float,
                          particle_lifetime_max: float,
                          particle_scale: float = 1.0,
                          fade_particles: bool = True):
    """Returns an emitter that emits its particles at a constant rate for a given amount of time"""
    particle_factory: Type[
        arcadeplus.LifetimeParticle] = arcadeplus.LifetimeParticle
    if fade_particles:
        particle_factory = arcadeplus.FadeParticle
    return arcadeplus.Emitter(
        center_xy=center_xy,
        emit_controller=arcadeplus.EmitterIntervalWithTime(
            emit_interval, emit_duration),
        particle_factory=lambda emitter: particle_factory(
            filename_or_texture=random.choice(filenames_and_textures),
            change_xy=arcadeplus.rand_on_circle((0.0, 0.0), particle_speed),
            lifetime=random.uniform(particle_lifetime_min,
                                    particle_lifetime_max),
            scale=particle_scale))
Beispiel #8
0
def test_rand_on_circle():
    """Smoke test"""
    arcadeplus.rand_on_circle((10.0, 20.0), 15.5)