diff options
author | David Thompson <dthompson2@worcester.edu> | 2018-08-21 10:45:35 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2018-08-23 08:02:20 -0400 |
commit | 0e67d24f8d155e0a0864a0083fb9f8e622f95ee6 (patch) | |
tree | 4c9859c10a5c714c19879c94976e00ae8cf196f8 /chickadee.scm | |
parent | e61e1f84c10934221154d312cc47758be2e90133 (diff) |
Add default game loop error handler.
* chickadee.scm (default-error-handler): New procedure.
(run-game): Set default value for 'error' arg to
'default-error-handler'.
* chickadee/sdl.scm (run-game/sdl): Ditto.
Diffstat (limited to 'chickadee.scm')
-rw-r--r-- | chickadee.scm | 14 |
1 files changed, 10 insertions, 4 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 () |