summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson@member.fsf.org>2013-12-02 20:30:47 -0500
committerDavid Thompson <dthompson@member.fsf.org>2013-12-02 20:30:47 -0500
commit352ba64d8a56b0bf4c1041c632ca1987788fd5db (patch)
tree21dede7e4959d94bd47e37558d91b4bb9aaab5b3
parentbf3ef3a95649c565f14278aa7fe6dc5269505825 (diff)
Use signal-fold in example.
-rw-r--r--examples/rewrite-test.scm13
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"))