summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2016-06-20 21:49:11 -0400
committerDavid Thompson <dthompson2@worcester.edu>2016-06-20 21:49:11 -0400
commitbdefee178b656a8f1ab83732f0e6461ad2d2ff50 (patch)
tree94b464c0f1d6e1e55e24775d2abe94bb53557f1d /examples
parentb3c577c1d8ae32d93fe7cf3986a2a81a011b1db3 (diff)
render: particles: Allow finer control over particle emission.
* sly/render/particles.scm (<particle-system>)[emit-rate]: Delete. [emit-interval, emit-count]: New fields. (make-particle-system): Delete emit-rate argument. Add emit-interval and emit-count arguments. (render-particles): Rewrite to use emit-rate and emit-count. * examples/particles.scm: Update example to use new API.
Diffstat (limited to 'examples')
-rw-r--r--examples/particles.scm12
1 files changed, 7 insertions, 5 deletions
diff --git a/examples/particles.scm b/examples/particles.scm
index e9af860..5e7ee7a 100644
--- a/examples/particles.scm
+++ b/examples/particles.scm
@@ -23,7 +23,8 @@
(load "common.scm")
(define (particle-position n time life-span)
- (polar2 (* time 2) (* n n)))
+ (polar2 (+ (* time 2) (* (modulo n 17) (/ time 8)))
+ (+ (/ (sin (* n n)) 7) pi/2)))
(define-signal texture
(on-start (load-texture "images/bullet.png")
@@ -32,13 +33,14 @@
(define-signal particle-system
(signal-let ((texture texture))
(make-particle-system #:texture texture
- #:emit-rate 4
- #:life-span 200
+ #:emit-interval 2
+ #:emit-count 16
+ #:life-span 60
#:renderer (make-simple-particle-renderer
particle-position))))
(define-signal batch
- (on-start (make-sprite-batch 1024)))
+ (on-start (make-sprite-batch 4096)))
(define-signal scene
(signal-let ((particle-system particle-system)
@@ -47,7 +49,7 @@
(if batch
(with-camera (2d-camera #:area (make-rect 0 0 640 480))
(with-blend-mode (make-blend-mode 'src-alpha 'one)
- (move (vector2 320 240)
+ (move (vector2 320 180)
(render-particles particle-system batch time))))
render-nothing)))