-
Notifications
You must be signed in to change notification settings - Fork 1
Particles
TODO: create some more examples such as explosins, water and stuff like that.
Particle systems, as currently implemented in Windstille, consists of two main sub parts, a drawer object and a distribution object. The drawer gets the particles position and parameter and draws it, while the distribution is used to spawn the particles. Distributions are geometric shapes like lines, rectangles or circles.
The job of the drawer object is to render the particles, it gets the position, lifetime ond other parameter of the particle and can then decide how to render it with that information. New Drawer objects can be added with relative ease.
Draws a image at the position of each particle.
Draws a line from the current particle position to the position the particle had a frame earlier.
In source code Distribution is currently called Randomizer, this needs to be cleaned up.
The Distribution object decides at which position the next Particle should be spawned. In most cases the distribution object defines a geometric shape in which new Particles get created.
drawer that draws the particle
description of a distribution object from which particles spawn
number of particles that can be on the screen at once
position of the particle system
z position, used for drawing order
layer name to which the particles get drawn, can be:
- "highlight"
- "light"
- "color"
direction into which particles are emitted
speed of the emitted particles
;; -*- scheme -*-
(particle-systems
;; Fire sparks
(particle-system
(drawer (spark-drawer (color 1.0 0.5 0.5)))
(z-pos 900)
(pos 0 32)
(layer "highlight")
(velocity 400 650)
(cone -115 -65)
(gravity 0 1)
(distribution (line-distribution (x1 -50) (y1 0) (x2 50) (y2 0))))
;; Fire smoke
(particle-system
(pos 0 32)
(lifetime 8)
(count 30)
(z-pos -200)
(drawer (surface-drawer (image "images/particles/smoke2.png")
(blendfunc-src "src_alpha")
(blendfunc-dst "one_minus_src_alpha")))
(velocity 10 20)
(cone -115 -65)
(gravity 0 -0.05)
(size 1.0 3.0)
(distribution (line-distribution (x1 -50) (y1 0) (x2 50) (y2 0))))
;; Fire itself
(particle-system
(pos 0 0)
(count 75)
(z-pos 1000)
(layer "highlight")
(velocity 200 300)
(cone -95 -85)
(gravity 0 -0.05)
(size 1.5 1.0)
(distribution (line-distribution (x1 -50) (y1 0) (x2 50) (y2 0)))
(drawer (surface-drawer (image "images/particles/smoke.png")
(blendfunc-src "src_alpha")
(blendfunc-dst "one"))))
)
;; EOF ;;
And here an older version of the example code in action:
[https://www.youtube.com/watch?v=q-9miRwcLwk]