diff options
-rw-r--r-- | chickadee.scm | 14 | ||||
-rw-r--r-- | chickadee/sdl.scm | 2 |
2 files changed, 11 insertions, 5 deletions
diff --git a/chickadee.scm b/chickadee.scm index 09212fe..4176b5d 100644 --- a/chickadee.scm +++ b/chickadee.scm @@ -16,7 +16,8 @@ ;;; <http://www.gnu.org/licenses/>. (define-module (chickadee) - #:export (run-game + #:export (default-error-handler + run-game abort-game)) @@ -43,11 +44,14 @@ (set! stack (make-stack #t 3)))))) (define-syntax-rule (with-error-handling handler body ...) - (call-with-error-handling handler (lambda () body ...))) + (call-with-error-handling handler (lambda () body ...))) + +(define (default-error-handler stack key args) + (apply throw key args)) ;;; -;;; Game loop core +;;; Game loop kernel ;;; (define game-loop-prompt-tag (make-prompt-tag 'game-loop)) @@ -55,7 +59,9 @@ (define (abort-game) (abort-to-prompt game-loop-prompt-tag #f)) -(define* (run-game #:key update render time error (update-hz 60)) +(define* (run-game #:key update render time + (error default-error-handler) + (update-hz 60)) (let ((timestep (round (/ 1000 update-hz)))) (call-with-prompt game-loop-prompt-tag (lambda () diff --git a/chickadee/sdl.scm b/chickadee/sdl.scm index bb8d5e3..b00e30e 100644 --- a/chickadee/sdl.scm +++ b/chickadee/sdl.scm @@ -85,7 +85,7 @@ (controller-press (const #t)) (controller-release (const #t)) (controller-move (const #t)) - (error (const #t))) + (error default-error-handler)) (sdl-init) (false-if-exception (mixer-init)) (open-audio) |