From d60cca3ccff443e10fabe9a01045e4fd7169d563 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sun, 19 Aug 2018 22:49:12 -0400 Subject: Make the game loop modular! This is really cool! Now users can plug in whatever backend they'd like and are not forced to use SDL and OpenGL. Thanks to Chris Webber for showing me the Lux library for Racket that does exactly this. * chickadee.scm (run-game): Remove all SDL/OpenGL code, replace with generic render/update keyword arguments. (run-game/sdl): New procedure. * examples/lines.scm: Update for API breakage. * examples/nine-patch.scm: Ditto. * examples/sprite.scm: Ditto. * examples/text.scm: Ditto. * examples/tiled.scm: Ditto. --- examples/text.scm | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'examples/text.scm') diff --git a/examples/text.scm b/examples/text.scm index 37ac22c..fd299b7 100644 --- a/examples/text.scm +++ b/examples/text.scm @@ -15,12 +15,8 @@ (draw-text font "The quick brown fox jumps over the lazy dog" (vec2 100.0 100.0))) -(add-hook! load-hook load) -(add-hook! draw-hook draw) -(add-hook! quit-hook abort-game) -(add-hook! key-press-hook - (lambda (key scan modifiers repeat?) - (when (eq? key 'q) - (abort-game)))) +(define (key-press key scan modifiers repeat?) + (when (eq? key 'q) + (abort-game))) -(run-game) +(run-game/sdl #:load load #:draw draw #:key-press key-press) -- cgit v1.2.3