summaryrefslogtreecommitdiff
path: root/2d/game.scm
diff options
context:
space:
mode:
authorDavid Thompson <dthompson@member.fsf.org>2013-12-01 10:06:19 -0500
committerDavid Thompson <dthompson@member.fsf.org>2013-12-01 10:06:19 -0500
commit6cd84e2f0bb6a08fddbf1a9cce31fd1192f1f248 (patch)
tree61341aa7a3274a26cd38730ab7c3696b4e27fd1f /2d/game.scm
parentee4c0fc7438b4eb30957a4f32eb72d19c079709d (diff)
Add arrows signal.
* 2d/game.scm (arrows): New signal.
Diffstat (limited to '2d/game.scm')
-rw-r--r--2d/game.scm12
1 files changed, 12 insertions, 0 deletions
diff --git a/2d/game.scm b/2d/game.scm
index 72980fd..c2ad0bc 100644
--- a/2d/game.scm
+++ b/2d/game.scm
@@ -43,6 +43,7 @@
window-size
key-last-pressed
key-down?
+ arrows
mouse-position
mouse-down?
current-fps))
@@ -194,6 +195,17 @@ time in milliseconds that has passed since the last game update."
"Return a signal for BUTTON."
(signal-hash-ref mouse-signals button))
+(define arrows (signal-lift4 (lambda (up? down? left? right?)
+ (let ((up (if up? -1 0))
+ (down (if down? 1 0))
+ (left (if left? -1 0))
+ (right (if right? 1 0)))
+ (vector2 (+ left right) (+ up down))))
+ (key-down? 'up)
+ (key-down? 'down)
+ (key-down? 'left)
+ (key-down? 'right)))
+
(define (handle-event e)
"Call the relevant callbacks for the event E."
(case (SDL:event:type e)