oreolek
/
particles
Archived
1
0
Fork 0
This repository has been archived on 2019-04-06. You can view files and clone it, but cannot push or open issues or pull requests.
particles/emitter.rb

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