Re-add key-pressed? and key-released? procedures.
authorDavid Thompson <dthompson2@worcester.edu>
Fri, 14 Dec 2018 02:32:32 +0000 (21:32 -0500)
committerDavid Thompson <dthompson2@worcester.edu>
Fri, 14 Dec 2018 02:32:32 +0000 (21:32 -0500)
* chickadee.scm (key-pressed?, key-released?): New procedures.
* examples/grid.scm: Remove (sdl2 input keyboard) import.

chickadee.scm
examples/grid.scm

index 3c10880..73aeae9 100644 (file)
@@ -25,6 +25,7 @@
   #:use-module (sdl2)
   #:use-module (sdl2 events)
   #:use-module (sdl2 input game-controller)
+  #:use-module ((sdl2 input keyboard) #:prefix sdl2:)
   #:use-module (sdl2 input joystick)
   #:use-module (sdl2 input text)
   #:use-module (sdl2 mixer)
   #:use-module (chickadee render gl)
   #:use-module (chickadee render gpu)
   #:use-module (chickadee render viewport)
-  #:export (current-window
+  #:export (key-pressed?
+            key-released?
+            current-window
             run-game)
   #:re-export (abort-game))
 
+(define (key-pressed? key)
+  "Return #t if KEY is currently being pressed."
+  (sdl2:key-pressed? key))
+
+(define (key-released? key)
+  "Return #t if KEY is not currently being pressed."
+  (sdl2:key-released? key))
+
 (define *controllers* (make-hash-table))
 
 (define (lookup-controller joystick-id)
index 0234746..f20f64d 100644 (file)
@@ -6,8 +6,7 @@
              (chickadee render color)
              (chickadee render font)
              (chickadee render shapes)
-             (chickadee render sprite)
-             (sdl2 input keyboard))
+             (chickadee render sprite))
 
 (define grid (make-grid))
 (define item-color (make-color 0.7 0.0 0.0 0.5))