def emitter_36(): """Moving emitter. Particles spawn relative to emitter.""" class MovingEmitter(arcade.Emitter): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.elapsed = 0.0 def update(self): super().update() self.elapsed += 1 / 60 self.center_x = sine_wave(self.elapsed, 0, SCREEN_WIDTH, SCREEN_WIDTH / 100) self.center_y = sine_wave(self.elapsed, 0, SCREEN_HEIGHT, SCREEN_HEIGHT / 100) e = MovingEmitter( center_xy=CENTER_POS, emit_controller=arcade.EmitInterval(0.005), particle_factory=lambda emitter: arcade.FadeParticle( filename_or_texture=TEXTURE, change_xy=arcade.rand_in_circle((0.0, 0.0), 0.1), lifetime=random.uniform(1.5, 5.5), scale=random.uniform(0.05, 0.2) ) ) return emitter_36.__doc__, e
def emitter_12(): """Infinite emitting w/ eternal particle""" e = arcade.Emitter( pos=CENTER_POS, emit_controller=arcade.EmitInterval(0.02), particle_factory=lambda emitter: arcade.EternalParticle( filename_or_texture=TEXTURE, vel=arcade.rand_in_circle(Vec2d.zero(), PARTICLE_SPEED_FAST), scale=DEFAULT_SCALE, alpha=DEFAULT_ALPHA)) return emitter_12.__doc__, e
def __init__(self): self.w = 600 self.h = 600 arcade.Window.__init__(self, self.w, self.h, "Particles!") arcade.set_background_color(arcade.color.EERIE_BLACK) # Sprite for particle from image (try changing to other item numbers! 17 is hearts!) self.text_blue = arcade.load_texture( "Sprites/PNG/Items/platformPack_item001.png") # Sprite for particle pregenerated self.text_red = arcade.make_soft_circle_texture(20, arcade.color.RED) self.text_green = arcade.make_soft_square_texture( 50, arcade.color.GREEN, 200, 150) # Timer for cosine/sine purposes later self.timer = 0 # Empty list to store our emitters for easy drawing and updating self.emitters = [] # Make the center, moving emitter self.fountain = arcade.Emitter( center_xy=(self.w / 2, self.h / 2), # Position emit_controller=arcade.EmitInterval( 0.01), # When to make more particles particle_factory=lambda emitter: arcade. FadeParticle( # Type of particle filename_or_texture=self.text_blue, # Particle texture change_xy=arcade.rand_in_circle( (0, 0), 4.5), # Particle velocity lifetime=1.0, # Particle lifetime scale=0.5, # Particle scaling ), ) self.cursor = arcade.Emitter( center_xy=(self.w / 2, self.h / 2), emit_controller=arcade.EmitMaintainCount( 30), # Alway keep 30 on screen particle_factory=lambda emitter: arcade. LifetimeParticle( # Stay bright till end filename_or_texture=self.text_red, change_xy=(random.uniform(-1, 1), random.uniform(-1, 1)), lifetime=random.random( ), # die out at random times, or else this looked weird scale=1, ), ) # Add our current, always-on emitters to the list self.emitters.extend([self.fountain, self.cursor])
def __init__(self, center_position: Tuple[float, float]): """ :param center_position: tuple of x and y coordinates """ super().__init__( center_xy=center_position, emit_controller=arcade.EmitInterval(0.003), particle_factory=lambda emitter: arcade.LifetimeParticle( filename_or_texture= ":resources:images/pinball/pool_cue_ball.png", change_xy=arcade.rand_vec_spread_deg(180, 25, 1.0), lifetime=random.uniform(self.PARTICLE_LIFETIME - 1.0, self. PARTICLE_LIFETIME), scale=0.1, alpha=32))