diff options
-rw-r--r-- | 2d/game.scm | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/2d/game.scm b/2d/game.scm index 1fb543a..e6c0161 100644 --- a/2d/game.scm +++ b/2d/game.scm @@ -43,7 +43,9 @@ window-size key-last-pressed key-down? - arrows + key-directions + key-arrows + key-wasd mouse-position mouse-down? current-fps)) @@ -195,16 +197,20 @@ 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 (key-directions up down left right) + (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 key-arrows (key-directions 'up 'down 'left 'right)) +(define key-wasd (key-directions 'w 's 'a 'd)) (define (handle-event e) "Call the relevant callbacks for the event E." |