From bdefee178b656a8f1ab83732f0e6461ad2d2ff50 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Mon, 20 Jun 2016 21:49:11 -0400 Subject: render: particles: Allow finer control over particle emission. * sly/render/particles.scm ()[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. --- examples/particles.scm | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'examples') 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))) -- cgit v1.2.3