diff options
author | David Thompson <dthompson@member.fsf.org> | 2013-09-04 20:40:35 -0400 |
---|---|---|
committer | David Thompson <dthompson@member.fsf.org> | 2013-09-06 00:09:29 -0400 |
commit | 937f39b8c275bc191e865d1f1a7088a7029eaa53 (patch) | |
tree | fe38420757b92f4404e5df235041ef21d7fbf3a8 | |
parent | 8760f1f437f847f6434665b0e52e6db84f82aab5 (diff) |
Update README with new minimal example.
-rw-r--r-- | README.org | 59 |
1 files changed, 21 insertions, 38 deletions
@@ -22,44 +22,23 @@ #+BEGIN_SRC scheme (use-modules (2d sprite) - (2d game-loop) - (2d window) - (2d helpers)) - - (define window-width 800) - (define window-height 600) - - ;; Open the window. - (open-window window-width window-height) - - ;; Load a sprite and center it on the screen. - (define sprite - (load-sprite "sprite.png" - #:position (vector (/ window-width 2) - (/ window-height 2)))) - - (define (quit-demo) - (close-window) - (quit)) - - (define (key-down key mod unicode) - (cond ((any-equal? key 'escape 'q) - (quit-demo)))) - - ;; Draw our sprite - (define (render) - (draw-sprite sprite)) - - ;; Register hooks. Lambdas are used as "trampolines" so that render - ;; and key-down can be redefined later and the hooks will call the - ;; updated procedures. - (add-hook! on-quit-hook (lambda () (quit-demo))) - (add-hook! on-render-hook (lambda () (render))) - (add-hook! on-key-down-hook (lambda (key mod unicode) (key-down key mod unicode))) - - ;; Start the game loop. - ;; The render callback will be called through this procedure. - (run-game-loop) + (2d game) + (2d vector2)) + + (define (demo-sprite) + (load-sprite "images/sprite.png" + #:position (vector2 320 240))) + + (define-scene demo + #:title "Demo" + #:draw (lambda (sprite) (draw-sprite sprite)) + #:state (demo-sprite)) + + (define-game simple + #:title "Simple Demo" + #:first-scene demo) + + (run-game simple) #+END_SRC ** Features @@ -272,6 +251,10 @@ guile -L .. simple.scm #+END_SRC + To quit an example: + - Close the window + - Press the =ESCAPE= or =Q= key + ** Platforms Guile-2d supports GNU/Linux currently. OS X support is in the |