diff options
author | David Thompson <dthompson@member.fsf.org> | 2013-09-04 20:36:53 -0400 |
---|---|---|
committer | David Thompson <dthompson@member.fsf.org> | 2013-09-06 00:09:29 -0400 |
commit | 8760f1f437f847f6434665b0e52e6db84f82aab5 (patch) | |
tree | d1da33cb2e1a5a31ceab763e1874d820fa06f5ae /examples | |
parent | 2b0741f91d2d782ab83a2c78613c1359e6d6cc31 (diff) |
Update simple example.
I am loving how few lines it takes to create a running application.
Diffstat (limited to 'examples')
-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) |