summaryrefslogtreecommitdiff
path: root/2d
diff options
context:
space:
mode:
Diffstat (limited to '2d')
-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)