def emitter_8():
    """Burst, emit from center, velocity in rectangle"""
    e = arcade.Emitter(center_xy=CENTER_POS,
                       emit_controller=arcade.EmitBurst(BURST_PARTICLE_COUNT),
                       particle_factory=lambda emitter: arcade.
                       LifetimeParticle(filename_or_texture=TEXTURE,
                                        change_xy=arcade.rand_in_rect(
                                            (-2.0, -2.0), 4.0, 4.0),
                                        lifetime=DEFAULT_PARTICLE_LIFETIME,
                                        scale=DEFAULT_SCALE,
                                        alpha=DEFAULT_ALPHA))
    return emitter_8.__doc__, e
def emitter_21():
    """Interval, emit from center, velocity in rectangle"""
    e = arcade.Emitter(
        pos=CENTER_POS,
        emit_controller=arcade.EmitterIntervalWithTime(DEFAULT_EMIT_INTERVAL,
                                                       DEFAULT_EMIT_DURATION),
        particle_factory=lambda emitter: arcade.LifetimeParticle(
            filename_or_texture=TEXTURE,
            vel=arcade.rand_in_rect(Vec2d(-2.0, -2.0), 4.0, 4.0),
            lifetime=DEFAULT_PARTICLE_LIFETIME,
            scale=DEFAULT_SCALE,
            alpha=DEFAULT_ALPHA))
    return emitter_21.__doc__, e
Ejemplo n.º 3
0
    def __init__(self):
        super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)

        # Set the working directory (where we expect to find files) to the same
        # directory this .py file is in. You can leave this out of your own
        # code, but it is needed to easily run the examples using "python -m"
        # as mentioned at the top of this program.
        file_path = os.path.dirname(os.path.abspath(__file__))
        os.chdir(file_path)

        arcade.set_background_color(arcade.color.BLACK)
        self.emitters = []
        self.frametime_plotter = FrametimePlotter()

        self.launch_firework(0)
        arcade.schedule(self.launch_spinner, 4.0)

        stars = arcade.Emitter(
            center_xy=(0.0, 0.0),
            emit_controller=arcade.EmitMaintainCount(20),
            particle_factory=lambda emitter: AnimatedAlphaParticle(
                filename_or_texture=random.choice(STAR_TEXTURES),
                change_xy=(0.0, 0.0),
                start_alpha=0,
                duration1=random.uniform(2.0, 6.0),
                mid_alpha=128,
                duration2=random.uniform(2.0, 6.0),
                end_alpha=0,
                center_xy=arcade.rand_in_rect((0.0, 0.0), SCREEN_WIDTH, SCREEN_HEIGHT)
            )
        )
        self.emitters.append(stars)

        self.cloud = arcade.Emitter(
            center_xy=(50, 500),
            change_xy=(0.15, 0),
            emit_controller=arcade.EmitMaintainCount(60),
            particle_factory=lambda emitter: AnimatedAlphaParticle(
                filename_or_texture=random.choice(CLOUD_TEXTURES),
                change_xy=(_Vec2(arcade.rand_in_circle((0.0, 0.0), 0.04)) + _Vec2(0.1, 0)).as_tuple(),
                start_alpha=0,
                duration1=random.uniform(5.0, 10.0),
                mid_alpha=255,
                duration2=random.uniform(5.0, 10.0),
                end_alpha=0,
                center_xy=arcade.rand_in_circle((0.0, 0.0), 50)
            )
        )
        self.emitters.append(self.cloud)
def emitter_5():
    """Burst, emit in rectangle"""
    width, height = 200, 100
    centering_offset = Vec2d(-width / 2, -height / 2)
    e = arcade.Emitter(
        pos=CENTER_POS,
        emit_controller=arcade.EmitBurst(BURST_PARTICLE_COUNT),
        particle_factory=lambda emitter: arcade.LifetimeParticle(
            filename_or_texture=TEXTURE,
            vel=arcade.rand_in_circle(Vec2d.zero(), PARTICLE_SPEED_SLOW),
            lifetime=DEFAULT_PARTICLE_LIFETIME,
            pos=arcade.rand_in_rect(centering_offset, width, height),
            scale=DEFAULT_SCALE,
            alpha=DEFAULT_ALPHA))
    return emitter_5.__doc__, e
def emitter_18():
    """Interval, emit in rectangle"""
    width, height = 200, 100
    centering_offset = (-width / 2, -height / 2)
    e = arcade.Emitter(
        center_xy=CENTER_POS,
        emit_controller=arcade.EmitterIntervalWithTime(DEFAULT_EMIT_INTERVAL,
                                                       DEFAULT_EMIT_DURATION),
        particle_factory=lambda emitter: arcade.LifetimeParticle(
            filename_or_texture=TEXTURE,
            change_xy=arcade.rand_in_circle((0.0, 0.0), PARTICLE_SPEED_SLOW),
            lifetime=DEFAULT_PARTICLE_LIFETIME,
            center_xy=arcade.rand_in_rect(centering_offset, width, height),
            scale=DEFAULT_SCALE,
            alpha=DEFAULT_ALPHA))
    return emitter_18.__doc__, e
Ejemplo n.º 6
0
def test_rand_in_rect():
    """Smoke test"""
    arcade.rand_in_rect((10.0, 20.0), 30.5, 5.1)