summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am4
-rw-r--r--chickadee.scm256
-rw-r--r--chickadee/game-loop.scm98
-rw-r--r--chickadee/sdl.scm207
-rw-r--r--doc/api.texi27
-rw-r--r--examples/grid.scm3
-rw-r--r--examples/lines.scm5
-rw-r--r--examples/nine-patch.scm5
-rw-r--r--examples/sprite.scm5
-rw-r--r--examples/text.scm8
-rw-r--r--examples/tiled.scm13
11 files changed, 313 insertions, 318 deletions
diff --git a/Makefile.am b/Makefile.am
index dbcc9ba..d80831a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -41,6 +41,7 @@ godir=$(libdir)/guile/$(GUILE_EFFECTIVE_VERSION)/ccache
SOURCES = \
chickadee/config.scm \
chickadee/utils.scm \
+ chickadee/game-loop.scm \
chickadee/json.scm \
chickadee/heap.scm \
chickadee/array-list.scm \
@@ -75,8 +76,7 @@ SOURCES = \
chickadee/scripting/script.scm \
chickadee/scripting/channel.scm \
chickadee/scripting.scm \
- chickadee.scm \
- chickadee/sdl.scm
+ chickadee.scm
EXTRA_DIST += \
COPYING \
diff --git a/chickadee.scm b/chickadee.scm
index 386e99f..3c10880 100644
--- a/chickadee.scm
+++ b/chickadee.scm
@@ -1,5 +1,5 @@
;;; Chickadee Game Toolkit
-;;; Copyright © 2016, 2018 David Thompson <davet@gnu.org>
+;;; Copyright © 2018 David Thompson <davet@gnu.org>
;;;
;;; Chickadee is free software: you can redistribute it and/or modify
;;; it under the terms of the GNU General Public License as published
@@ -15,84 +15,194 @@
;;; along with this program. If not, see
;;; <http://www.gnu.org/licenses/>.
+;;; Commentary:
+;;
+;; Simple SDL + OpenGL game loop implementation.
+;;
+;;; Code:
+
(define-module (chickadee)
- #:export (run-game
- abort-game))
+ #:use-module (sdl2)
+ #:use-module (sdl2 events)
+ #:use-module (sdl2 input game-controller)
+ #:use-module (sdl2 input joystick)
+ #:use-module (sdl2 input text)
+ #:use-module (sdl2 mixer)
+ #:use-module (sdl2 video)
+ #:use-module (chickadee game-loop)
+ #:use-module (chickadee math matrix)
+ #:use-module (chickadee render)
+ #:use-module (chickadee render color)
+ #:use-module (chickadee render gl)
+ #:use-module (chickadee render gpu)
+ #:use-module (chickadee render viewport)
+ #:export (current-window
+ run-game)
+ #:re-export (abort-game))
-
-;;;
-;;; Error handling
-;;;
+(define *controllers* (make-hash-table))
-(define (call-with-error-handling handler thunk)
- (if handler
- (let ((stack #f))
- (catch #t
- (lambda ()
- (thunk)
- #f)
- (lambda (key . args)
- (handler stack key args)
- #t)
- (lambda (key . args)
- (set! stack (make-stack #t 3)))))
- (begin
- (thunk)
- #f)))
+(define (lookup-controller joystick-id)
+ (hashv-ref *controllers* joystick-id))
-(define-syntax-rule (with-error-handling handler body ...)
- (call-with-error-handling handler (lambda () body ...)))
+(define (add-controller joystick-index)
+ (let ((controller (open-game-controller joystick-index)))
+ (hashv-set! *controllers*
+ (joystick-instance-id
+ (game-controller-joystick controller))
+ controller)
+ controller))
-(define (default-error-handler stack key args)
- (apply throw key args))
+(define (remove-controller joystick-id)
+ (hashv-remove! *controllers* joystick-id))
-
-;;;
-;;; Game loop kernel
-;;;
-
-(define game-loop-prompt-tag (make-prompt-tag 'game-loop))
+(define (open-all-controllers)
+ (let loop ((i 0))
+ (when (< i (num-joysticks))
+ (when (game-controller-index? i)
+ (add-controller i))
+ (loop (+ i 1)))))
-(define (abort-game)
- (abort-to-prompt game-loop-prompt-tag #f))
+(define current-window (make-parameter #f))
-(define* (run-game #:key update render time error
- (update-hz 60))
- (let ((timestep (round (/ 1000 update-hz))))
- (call-with-prompt game-loop-prompt-tag
+(define* (run-game #:key
+ (window-title "Chickadee!")
+ (window-width 640)
+ (window-height 480)
+ window-fullscreen?
+ (update-hz 60)
+ (load (const #t))
+ (update (const #t))
+ (draw (const #t))
+ (quit abort-game)
+ (key-press (const #t))
+ (key-release (const #t))
+ (text-input (const #t))
+ (mouse-press (const #t))
+ (mouse-release (const #t))
+ (mouse-move (const #t))
+ (controller-add (const #t))
+ (controller-remove (const #t))
+ (controller-press (const #t))
+ (controller-release (const #t))
+ (controller-move (const #t))
+ error)
+ (sdl-init)
+ (false-if-exception (mixer-init))
+ (open-audio)
+ (start-text-input)
+ (open-all-controllers)
+ (let* ((window (make-window #:opengl? #t
+ #:title window-title
+ #:size (list window-width window-height)
+ #:fullscreen? window-fullscreen?))
+ (gl-context (make-gl-context window))
+ (default-viewport (make-viewport 0 0 window-width window-height))
+ (default-projection (orthographic-projection 0 window-width
+ window-height 0
+ 0 1)))
+ (define (invert-y y)
+ ;; SDL's origin is the top-left, but our origin is the bottom
+ ;; left so we need to invert Y coordinates that SDL gives us.
+ (- window-height y))
+ (define (input-sdl)
+ (define (process-event event)
+ (cond
+ ((quit-event? event)
+ (quit))
+ ((keyboard-down-event? event)
+ (key-press (keyboard-event-key event)
+ (keyboard-event-scancode event)
+ (keyboard-event-modifiers event)
+ (keyboard-event-repeat? event)))
+ ((keyboard-up-event? event)
+ (key-release (keyboard-event-key event)
+ (keyboard-event-scancode event)
+ (keyboard-event-modifiers event)))
+ ((text-input-event? event)
+ (text-input (text-input-event-text event)))
+ ((mouse-button-down-event? event)
+ (mouse-press (mouse-button-event-button event)
+ (mouse-button-event-clicks event)
+ (mouse-button-event-x event)
+ (invert-y (mouse-button-event-y event))))
+ ((mouse-button-up-event? event)
+ (mouse-release (mouse-button-event-button event)
+ (mouse-button-event-x event)
+ (invert-y (mouse-button-event-y event))))
+ ((mouse-motion-event? event)
+ (mouse-move (mouse-motion-event-x event)
+ (invert-y (mouse-motion-event-y event))
+ (mouse-motion-event-x-rel event)
+ (- (mouse-motion-event-y-rel event))
+ (mouse-motion-event-buttons event)))
+ ((and (controller-device-event? event)
+ (eq? (controller-device-event-action event) 'added))
+ (controller-add (add-controller
+ (controller-device-event-which event))))
+ ((and (controller-device-event? event)
+ (eq? (controller-device-event-action event) 'removed))
+ (let ((controller (lookup-controller
+ (controller-device-event-which event))))
+ (controller-remove controller)
+ (remove-controller (controller-device-event-which event))
+ (close-game-controller controller)))
+ ((controller-button-down-event? event)
+ (controller-press (lookup-controller
+ (controller-button-event-which event))
+ (controller-button-event-button event)))
+ ((controller-button-up-event? event)
+ (controller-release (lookup-controller
+ (controller-button-event-which event))
+ (controller-button-event-button event)))
+ ((controller-axis-event? event)
+ (controller-move (lookup-controller
+ (controller-axis-event-which event))
+ (controller-axis-event-axis event)
+ (/ (controller-axis-event-value event) 32768.0)))))
+ ;; Process all pending events.
+ (let loop ((event (poll-event)))
+ (when event
+ (process-event event)
+ (loop (poll-event)))))
+ (define (update-sdl dt)
+ (input-sdl)
+ (update dt)
+ ;; Free any GPU resources that have been GC'd.
+ (gpu-reap!))
+ (define (render-sdl-opengl alpha)
+ ;; Switch to the null viewport to ensure that
+ ;; the default viewport will be re-applied and
+ ;; clear the screen.
+ (gpu-state-set! *viewport-state* null-viewport)
+ (with-viewport default-viewport
+ (with-projection default-projection
+ (draw alpha)))
+ (swap-gl-window window))
+ (dynamic-wind
+ (const #t)
+ (lambda ()
+ (parameterize ((current-window window))
+ ;; Attempt to activate vsync, if possible. Some systems do
+ ;; not support setting the OpenGL swap interval.
+ (catch #t
+ (lambda ()
+ (set-gl-swap-interval! 'vsync))
+ (lambda args
+ (display "warning: could not enable vsync\n"
+ (current-error-port))))
+ (load)
+ ;; Notify about all controllers that were already connected
+ ;; when the game was launched because SDL will not create
+ ;; events for them.
+ (hash-for-each (lambda (key controller)
+ (controller-add controller))
+ *controllers*)
+ (run-game* #:update update-sdl
+ #:render render-sdl-opengl
+ #:error error
+ #:time sdl-ticks
+ #:update-hz update-hz)))
(lambda ()
- ;; Catch SIGINT and kill the loop.
- (sigaction SIGINT
- (lambda (signum)
- (abort-game)))
- ;; A simple analogy is that we are filling up a bucket
- ;; with water. When the bucket fills up to a marked
- ;; line, we dump it out. Our water is time, and each
- ;; time we dump the bucket we update the game. Updating
- ;; the game on a fixed timestep like this yields a
- ;; stable simulation.
- (let loop ((previous-time (time))
- (buffer 0))
- (let* ((current-time (time))
- (delta (- current-time previous-time)))
- (let update-loop ((buffer (+ buffer delta)))
- (if (>= buffer timestep)
- ;; Short-circuit the update loop if an error
- ;; occurred, and reset the current time to now in
- ;; order to discard the undefined amount of time
- ;; that was spent handling the error.
- (if (with-error-handling error (update timestep))
- (loop (time) 0)
- (begin
- (usleep 1)
- (update-loop (- buffer timestep))))
- (begin
- ;; We render upon every iteration of the loop, and
- ;; thus rendering is decoupled from updating.
- ;; It's possible to render multiple times before
- ;; an update is performed.
- (if (with-error-handling error (render (/ buffer timestep)))
- (loop (time) 0)
- (loop current-time buffer))))))))
- (lambda (cont callback)
- #f))))
+ (delete-gl-context! gl-context)
+ (close-window! window)))))
diff --git a/chickadee/game-loop.scm b/chickadee/game-loop.scm
new file mode 100644
index 0000000..09f8a7b
--- /dev/null
+++ b/chickadee/game-loop.scm
@@ -0,0 +1,98 @@
+;;; Chickadee Game Toolkit
+;;; Copyright © 2016, 2018 David Thompson <davet@gnu.org>
+;;;
+;;; Chickadee is free software: you can redistribute it and/or modify
+;;; it under the terms of the GNU General Public License as published
+;;; by the Free Software Foundation, either version 3 of the License,
+;;; or (at your option) any later version.
+;;;
+;;; Chickadee is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;;; General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with this program. If not, see
+;;; <http://www.gnu.org/licenses/>.
+
+(define-module (chickadee game-loop)
+ #:export (run-game*
+ abort-game))
+
+
+;;;
+;;; Error handling
+;;;
+
+(define (call-with-error-handling handler thunk)
+ (if handler
+ (let ((stack #f))
+ (catch #t
+ (lambda ()
+ (thunk)
+ #f)
+ (lambda (key . args)
+ (handler stack key args)
+ #t)
+ (lambda (key . args)
+ (set! stack (make-stack #t 3)))))
+ (begin
+ (thunk)
+ #f)))
+
+(define-syntax-rule (with-error-handling handler body ...)
+ (call-with-error-handling handler (lambda () body ...)))
+
+(define (default-error-handler stack key args)
+ (apply throw key args))
+
+
+;;;
+;;; Game loop kernel
+;;;
+
+(define game-loop-prompt-tag (make-prompt-tag 'game-loop))
+
+(define (abort-game)
+ (abort-to-prompt game-loop-prompt-tag #f))
+
+(define* (run-game* #:key update render time error
+ (update-hz 60))
+ (let ((timestep (round (/ 1000 update-hz))))
+ (call-with-prompt game-loop-prompt-tag
+ (lambda ()
+ ;; Catch SIGINT and kill the loop.
+ (sigaction SIGINT
+ (lambda (signum)
+ (abort-game)))
+ ;; A simple analogy is that we are filling up a bucket
+ ;; with water. When the bucket fills up to a marked
+ ;; line, we dump it out. Our water is time, and each
+ ;; time we dump the bucket we update the game. Updating
+ ;; the game on a fixed timestep like this yields a
+ ;; stable simulation.
+ (let loop ((previous-time (time))
+ (buffer 0))
+ (let* ((current-time (time))
+ (delta (- current-time previous-time)))
+ (let update-loop ((buffer (+ buffer delta)))
+ (if (>= buffer timestep)
+ ;; Short-circuit the update loop if an error
+ ;; occurred, and reset the current time to now in
+ ;; order to discard the undefined amount of time
+ ;; that was spent handling the error.
+ (if (with-error-handling error (update timestep))
+ (loop (time) 0)
+ (begin
+ (usleep 1)
+ (update-loop (- buffer timestep))))
+ (begin
+ ;; We render upon every iteration of the loop, and
+ ;; thus rendering is decoupled from updating.
+ ;; It's possible to render multiple times before
+ ;; an update is performed.
+ (if (with-error-handling error (render (/ buffer timestep)))
+ (loop (time) 0)
+ (loop current-time buffer))))))))
+ (lambda (cont callback)
+ #f))))
diff --git a/chickadee/sdl.scm b/chickadee/sdl.scm
deleted file mode 100644
index 948b351..0000000
--- a/chickadee/sdl.scm
+++ /dev/null
@@ -1,207 +0,0 @@
-;;; Chickadee Game Toolkit
-;;; Copyright © 2018 David Thompson <davet@gnu.org>
-;;;
-;;; Chickadee is free software: you can redistribute it and/or modify
-;;; it under the terms of the GNU General Public License as published
-;;; by the Free Software Foundation, either version 3 of the License,
-;;; or (at your option) any later version.
-;;;
-;;; Chickadee is distributed in the hope that it will be useful, but
-;;; WITHOUT ANY WARRANTY; without even the implied warranty of
-;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-;;; General Public License for more details.
-;;;
-;;; You should have received a copy of the GNU General Public License
-;;; along with this program. If not, see
-;;; <http://www.gnu.org/licenses/>.
-
-;;; Commentary:
-;;
-;; Simple SDL + OpenGL game loop implementation.
-;;
-;;; Code:
-
-(define-module (chickadee sdl)
- #:use-module (sdl2)
- #:use-module (sdl2 events)
- #:use-module (sdl2 input game-controller)
- #:use-module (sdl2 input joystick)
- #:use-module (sdl2 input text)
- #:use-module (sdl2 mixer)
- #:use-module (sdl2 video)
- #:use-module (chickadee)
- #:use-module (chickadee math matrix)
- #:use-module (chickadee render)
- #:use-module (chickadee render color)
- #:use-module (chickadee render gl)
- #:use-module (chickadee render gpu)
- #:use-module (chickadee render viewport)
- #:export (current-window
- run-game/sdl))
-
-(define *controllers* (make-hash-table))
-
-(define (lookup-controller joystick-id)
- (hashv-ref *controllers* joystick-id))
-
-(define (add-controller joystick-index)
- (let ((controller (open-game-controller joystick-index)))
- (hashv-set! *controllers*
- (joystick-instance-id
- (game-controller-joystick controller))
- controller)
- controller))
-
-(define (remove-controller joystick-id)
- (hashv-remove! *controllers* joystick-id))
-
-(define (open-all-controllers)
- (let loop ((i 0))
- (when (< i (num-joysticks))
- (when (game-controller-index? i)
- (add-controller i))
- (loop (+ i 1)))))
-
-(define current-window (make-parameter #f))
-
-(define* (run-game/sdl #:key
- (window-title "Chickadee!")
- (window-width 640)
- (window-height 480)
- window-fullscreen?
- (update-hz 60)
- (load (const #t))
- (update (const #t))
- (draw (const #t))
- (quit abort-game)
- (key-press (const #t))
- (key-release (const #t))
- (text-input (const #t))
- (mouse-press (const #t))
- (mouse-release (const #t))
- (mouse-move (const #t))
- (controller-add (const #t))
- (controller-remove (const #t))
- (controller-press (const #t))
- (controller-release (const #t))
- (controller-move (const #t))
- error)
- (sdl-init)
- (false-if-exception (mixer-init))
- (open-audio)
- (start-text-input)
- (open-all-controllers)
- (let* ((window (make-window #:opengl? #t
- #:title window-title
- #:size (list window-width window-height)
- #:fullscreen? window-fullscreen?))
- (gl-context (make-gl-context window))
- (default-viewport (make-viewport 0 0 window-width window-height))
- (default-projection (orthographic-projection 0 window-width
- window-height 0
- 0 1)))
- (define (invert-y y)
- ;; SDL's origin is the top-left, but our origin is the bottom
- ;; left so we need to invert Y coordinates that SDL gives us.
- (- window-height y))
- (define (input-sdl)
- (define (process-event event)
- (cond
- ((quit-event? event)
- (quit))
- ((keyboard-down-event? event)
- (key-press (keyboard-event-key event)
- (keyboard-event-scancode event)
- (keyboard-event-modifiers event)
- (keyboard-event-repeat? event)))
- ((keyboard-up-event? event)
- (key-release (keyboard-event-key event)
- (keyboard-event-scancode event)
- (keyboard-event-modifiers event)))
- ((text-input-event? event)
- (text-input (text-input-event-text event)))
- ((mouse-button-down-event? event)
- (mouse-press (mouse-button-event-button event)
- (mouse-button-event-clicks event)
- (mouse-button-event-x event)
- (invert-y (mouse-button-event-y event))))
- ((mouse-button-up-event? event)
- (mouse-release (mouse-button-event-button event)
- (mouse-button-event-x event)
- (invert-y (mouse-button-event-y event))))
- ((mouse-motion-event? event)
- (mouse-move (mouse-motion-event-x event)
- (invert-y (mouse-motion-event-y event))
- (mouse-motion-event-x-rel event)
- (- (mouse-motion-event-y-rel event))
- (mouse-motion-event-buttons event)))
- ((and (controller-device-event? event)
- (eq? (controller-device-event-action event) 'added))
- (controller-add (add-controller
- (controller-device-event-which event))))
- ((and (controller-device-event? event)
- (eq? (controller-device-event-action event) 'removed))
- (let ((controller (lookup-controller
- (controller-device-event-which event))))
- (controller-remove controller)
- (remove-controller (controller-device-event-which event))
- (close-game-controller controller)))
- ((controller-button-down-event? event)
- (controller-press (lookup-controller
- (controller-button-event-which event))
- (controller-button-event-button event)))
- ((controller-button-up-event? event)
- (controller-release (lookup-controller
- (controller-button-event-which event))
- (controller-button-event-button event)))
- ((controller-axis-event? event)
- (controller-move (lookup-controller
- (controller-axis-event-which event))
- (controller-axis-event-axis event)
- (/ (controller-axis-event-value event) 32768.0)))))
- ;; Process all pending events.
- (let loop ((event (poll-event)))
- (when event
- (process-event event)
- (loop (poll-event)))))
- (define (update-sdl dt)
- (input-sdl)
- (update dt)
- ;; Free any GPU resources that have been GC'd.
- (gpu-reap!))
- (define (render-sdl-opengl alpha)
- ;; Switch to the null viewport to ensure that
- ;; the default viewport will be re-applied and
- ;; clear the screen.
- (gpu-state-set! *viewport-state* null-viewport)
- (with-viewport default-viewport
- (with-projection default-projection
- (draw alpha)))
- (swap-gl-window window))
- (dynamic-wind
- (const #t)
- (lambda ()
- (parameterize ((current-window window))
- ;; Attempt to activate vsync, if possible. Some systems do
- ;; not support setting the OpenGL swap interval.
- (catch #t
- (lambda ()
- (set-gl-swap-interval! 'vsync))
- (lambda args
- (display "warning: could not enable vsync\n"
- (current-error-port))))
- (load)
- ;; Notify about all controllers that were already connected
- ;; when the game was launched because SDL will not create
- ;; events for them.
- (hash-for-each (lambda (key controller)
- (controller-add controller))
- *controllers*)
- (run-game #:update update-sdl
- #:render render-sdl-opengl
- #:error error
- #:time sdl-ticks
- #:update-hz update-hz)))
- (lambda ()
- (delete-gl-context! gl-context)
- (close-window! window)))))
diff --git a/doc/api.texi b/doc/api.texi
index df68889..8254b13 100644
--- a/doc/api.texi
+++ b/doc/api.texi
@@ -8,16 +8,16 @@
@node Kernel
@section Kernel
-At the very core of Chickadee, in the @code{(chickadee)} module, lies
-an event loop. This loop, or ``kernel'', is responsible for ensuring
-that the game is updated at the desired interval, rendering the
-current state of the game world, and handling errors if they occur.
-The kernel implements what is known as a ``fixed timestep'' game loop,
-meaning that the game simulation will be advanced by a fixed interval
-of time and will never vary from frame to frame, unlike some other
-styles of game loops. The appropriately named @code{run-game} and
-@code{abort-game} procedures are the entry and exit points to the
-Chickadee game loop kernel.
+At the very core of Chickadee, in the @code{(chickadee game-loop)}
+module, lies an event loop. This loop, or ``kernel'', is responsible
+for ensuring that the game is updated at the desired interval,
+rendering the current state of the game world, and handling errors if
+they occur. The kernel implements what is known as a ``fixed
+timestep'' game loop, meaning that the game simulation will be
+advanced by a fixed interval of time and will never vary from frame to
+frame, unlike some other styles of game loops. The appropriately
+named @code{run-game*} and @code{abort-game} procedures are the entry
+and exit points to the Chickadee game loop kernel.
On its own, the kernel does not do very much at all. In order to
actually respond to input events, update game state, or render output,
@@ -79,10 +79,9 @@ Stop the currently running Chickadee game loop.
Since most users will want to write 2D/3D games with hardware
accelerated graphics rendering, controlled via keyboard, mouse, or
game controller, Chickadee comes with an easy to use engine just for
-this purpose in the @code{(chickadee sdl)} module:
-@code{run-game/sdl}.
+this purpose in the @code{(chickadee)} module: @code{run-game}.
-@deffn {Procedure} run-game/sdl [#:window-title "Chickadee!"] @
+@deffn {Procedure} run-game [#:window-title "Chickadee!"] @
[#:window-width 640] [#:window-height 480] @
[#:window-fullscreen? @code{#f}] [#:update-hz 60] @
[#:load] [#:update] [#:draw] [#:quit] @
@@ -91,7 +90,7 @@ this purpose in the @code{(chickadee sdl)} module:
[#:controller-add] [#:controller-remove] [#:controller-press] @
[#:controller-release] [#:controller-move] [#:error]
-Run the Chickadee game loop using the SDL engine.
+Run the Chickadee game loop using the SDL engine in OpenGL mode.
A new graphical window will be opened with @var{window-width} x
@var{window-height} as its dimensions, @var{window-title} as its
diff --git a/examples/grid.scm b/examples/grid.scm
index 6fab47a..0234746 100644
--- a/examples/grid.scm
+++ b/examples/grid.scm
@@ -7,7 +7,6 @@
(chickadee render font)
(chickadee render shapes)
(chickadee render sprite)
- (chickadee sdl)
(sdl2 input keyboard))
(define grid (make-grid))
@@ -82,4 +81,4 @@
(draw-filled-rect rect item-color)))
grid)))
-(run-game/sdl #:load load #:draw draw #:update update)
+(run-game #:load load #:draw draw #:update update)
diff --git a/examples/lines.scm b/examples/lines.scm
index f24ec25..b7a551a 100644
--- a/examples/lines.scm
+++ b/examples/lines.scm
@@ -3,8 +3,7 @@
(chickadee)
(chickadee math vector)
(chickadee render color)
- (chickadee render shapes)
- (chickadee sdl))
+ (chickadee render shapes))
(define lines
(list-tabulate 48
@@ -26,4 +25,4 @@
#:thickness thickness)))
lines))
-(run-game/sdl #:draw draw)
+(run-game #:draw draw)
diff --git a/examples/nine-patch.scm b/examples/nine-patch.scm
index d20ba06..ff5b9a8 100644
--- a/examples/nine-patch.scm
+++ b/examples/nine-patch.scm
@@ -3,8 +3,7 @@
(chickadee math vector)
(chickadee render font)
(chickadee render sprite)
- (chickadee render texture)
- (chickadee sdl))
+ (chickadee render texture))
(define image #f)
@@ -15,4 +14,4 @@
(draw-nine-patch image (make-rect 192.0 192.0 256.0 96.0) #:margin 6)
(draw-text "I am error." #v(200.0 266.0)))
-(run-game/sdl #:load load #:draw draw)
+(run-game #:load load #:draw draw)
diff --git a/examples/sprite.scm b/examples/sprite.scm
index ed968fb..0e8b4b3 100644
--- a/examples/sprite.scm
+++ b/examples/sprite.scm
@@ -1,8 +1,7 @@
(use-modules (chickadee)
(chickadee math vector)
(chickadee render sprite)
- (chickadee render texture)
- (chickadee sdl))
+ (chickadee render texture))
(define sprite #f)
@@ -12,4 +11,4 @@
(define (draw alpha)
(draw-sprite sprite #v(256.0 176.0)))
-(run-game/sdl #:load load #:draw draw)
+(run-game #:load load #:draw draw)
diff --git a/examples/text.scm b/examples/text.scm
index d181889..4758782 100644
--- a/examples/text.scm
+++ b/examples/text.scm
@@ -1,8 +1,8 @@
-(use-modules (chickadee math vector)
- (chickadee render font)
- (chickadee sdl))
+(use-modules (chickadee)
+ (chickadee math vector)
+ (chickadee render font))
(define (draw alpha)
(draw-text "Hello, world!" #v(260.0 240.0)))
-(run-game/sdl #:draw draw)
+(run-game #:draw draw)
diff --git a/examples/tiled.scm b/examples/tiled.scm
index 19332bb..5ff2b7f 100644
--- a/examples/tiled.scm
+++ b/examples/tiled.scm
@@ -2,7 +2,6 @@
(chickadee math vector)
(chickadee math rect)
(chickadee render tiled)
- (chickadee sdl)
(ice-9 match))
(define map #f)
@@ -24,9 +23,9 @@
('q (abort-game))
(_ #t)))
-(run-game/sdl #:window-width 320
- #:window-height 240
- #:window-title "tile map demo"
- #:load load
- #:draw draw
- #:key-press key-press)
+(run-game #:window-width 320
+ #:window-height 240
+ #:window-title "tile map demo"
+ #:load load
+ #:draw draw
+ #:key-press key-press)