summaryrefslogtreecommitdiff
path: root/2d
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2013-12-01 21:27:25 -0500
committerDavid Thompson <dthompson2@worcester.edu>2013-12-01 21:27:25 -0500
commitc57d365821ff9e8c13f2f001a535ba0e9399a135 (patch)
treeced82aa6556cbfc37ae9b5b07a2f61569ae19a70 /2d
parent9eb3737265f2da386bee5c73a0daf3977f9b5a41 (diff)
Add key-directions and key-wasd procedures.
* 2d/game.scm (key-directions, key-wasd): New procedures. (arrows, key-arrows): Renamed.
Diffstat (limited to '2d')
-rw-r--r--2d/game.scm28
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."