pxl8/demo/mod/vfx.fnl

76 lines
2 KiB
Text
Raw Normal View History

(local vfx {})
(fn vfx.explosion [ps x y ?opts]
(let [opts (or ?opts {})
color (or opts.color 208)
force (or opts.force 200)]
(ps:set_position x y)
(ps:set_colors color (+ color 15))
(ps:set_velocity (- force) force (- force) force)
(ps:set_gravity 0 100)
(ps:set_life 0.3 0.8)
(ps:set_size 1 3)
(ps:set_drag 0.98)
(ps:set_spawn_rate 0)
(ps:emit (or opts.count 50))))
(fn vfx.fire [ps x y ?opts]
(let [opts (or ?opts {})
width (or opts.width 50)
color (or opts.color 208)]
(ps:set_position x y)
(ps:set_spread width 5)
(ps:set_colors color (+ color 15))
(ps:set_velocity -20 20 -80 -40)
(ps:set_gravity 0 -30)
(ps:set_life 0.5 1.5)
(ps:set_size 1 2)
(ps:set_turbulence 30)
(ps:set_drag 0.95)
(ps:set_spawn_rate (or opts.rate 50))))
(fn vfx.rain [ps width ?opts]
(let [opts (or ?opts {})
wind (or opts.wind 0)
color (or opts.color 153)]
(ps:set_position (/ width 2) -10)
(ps:set_spread width 0)
(ps:set_colors color (+ color 3))
(ps:set_velocity (- wind 10) (+ wind 10) 300 400)
(ps:set_gravity 0 200)
(ps:set_life 1 2)
(ps:set_size 1 1)
(ps:set_drag 1)
(ps:set_spawn_rate (or opts.rate 100))))
(fn vfx.smoke [ps x y ?opts]
(let [opts (or ?opts {})
color (or opts.color 248)]
(ps:set_position x y)
(ps:set_spread 10 5)
(ps:set_colors color (+ color 7))
(ps:set_velocity -15 15 -30 -10)
(ps:set_gravity 0 -20)
(ps:set_life 1 3)
(ps:set_size 2 4)
(ps:set_turbulence 20)
(ps:set_drag 0.98)
(ps:set_spawn_rate (or opts.rate 20))))
(fn vfx.snow [ps width ?opts]
(let [opts (or ?opts {})
wind (or opts.wind 10)
color (or opts.color 15)]
(ps:set_position (/ width 2) -10)
(ps:set_spread width 0)
(ps:set_colors color color)
(ps:set_velocity (- wind 20) (+ wind 20) 30 60)
(ps:set_gravity 0 10)
(ps:set_life 3 6)
(ps:set_size 1 2)
(ps:set_turbulence 15)
(ps:set_drag 0.99)
(ps:set_spawn_rate (or opts.rate 30))))
vfx