22 lines
474 B
Ruby
22 lines
474 B
Ruby
# An emitter simply emits particles at a regular interval. In this case, every
|
|
# time spawn is called, a new particle is generated with a random angle of movement and speed.
|
|
class Emitter
|
|
def initialize(particles, fountain)
|
|
@particles = particles
|
|
@fountain = fountain
|
|
end
|
|
|
|
def spawn (x, y)
|
|
@particles.create(x, y, rand * 360, (1/@fountain.distance(x,y) * 6)+3)
|
|
end
|
|
|
|
def draw
|
|
@particles.draw
|
|
end
|
|
|
|
def update
|
|
@particles.update
|
|
end
|
|
end
|
|
|