diff options
author | David Thompson <dthompson@member.fsf.org> | 2013-12-02 20:30:47 -0500 |
---|---|---|
committer | David Thompson <dthompson@member.fsf.org> | 2013-12-02 20:30:47 -0500 |
commit | 352ba64d8a56b0bf4c1041c632ca1987788fd5db (patch) | |
tree | 21dede7e4959d94bd47e37558d91b4bb9aaab5b3 /examples | |
parent | bf3ef3a95649c565f14278aa7fe6dc5269505825 (diff) |
Use signal-fold in example.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/rewrite-test.scm | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/examples/rewrite-test.scm b/examples/rewrite-test.scm index 3582174..760afb0 100644 --- a/examples/rewrite-test.scm +++ b/examples/rewrite-test.scm @@ -12,15 +12,14 @@ (with-window (make-window #:title "FRP is cool" #:resolution (vector2 640 480) #:fullscreen? #f) + (define speed 4) + ;; Move when arrow keys are pressed. (define move - (make-signal - #:init (vector2 320 240) - #:transformer (lambda (value old from) - (v+ (vscale (signal-ref key-arrows) 4) old)) - #:filter (lambda (value old from) - (not (eq? from key-arrows))) - #:connectors (list key-arrows (time-every)))) + (signal-fold (lambda (direction position) + (v+ (vscale direction speed) position)) + (vector2 320 240) + (time-every key-arrows))) (define ghost-texture (load-texture "images/ghost.png")) |