diff options
Diffstat (limited to 'examples/simple.scm')
-rw-r--r-- | examples/simple.scm | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/examples/simple.scm b/examples/simple.scm index de66e6b..d770779 100644 --- a/examples/simple.scm +++ b/examples/simple.scm @@ -1,28 +1,18 @@ (use-modules (2d sprite) (2d game) - (2d game-loop) - (2d helpers) (2d vector2)) -(define sprite - (delay (load-sprite "images/sprite.png" - #:position (vector2 320 240)))) +(define (demo-sprite) + (load-sprite "images/sprite.png" + #:position (vector2 320 240))) -(define (key-down key mod unicode) - (cond ((any-equal? key 'escape 'q) - (quit-game-loop!)))) - -;; Draw our sprite -(define (render) - (draw-sprite (force sprite))) - -;; Register callbacks. -(add-hook! on-quit-hook quit-game-loop!) -(add-hook! on-render-hook (lambda () (render))) -(add-hook! on-key-down-hook (lambda (key mod unicode) - (key-down key mod unicode))) +(define-scene demo + #:title "Demo" + #:draw (lambda (sprite) (draw-sprite sprite)) + #:state (demo-sprite)) (define-game simple - #:title "Simple Demo") + #:title "Simple Demo" + #:first-scene demo) (run-game simple) |