diff options
author | David Thompson <dthompson2@worcester.edu> | 2017-05-02 22:38:25 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2017-05-02 22:38:25 -0400 |
commit | 499a07155e137c40589b8c8383ffa6c942ce15d6 (patch) | |
tree | f66e38c50916f664e61a46a0890bf6db110d970b /examples/buffer.scm | |
parent | dd8cf4614b6734cbd83d94a50b076a5e542c3aa4 (diff) |
Add buffer module.
* chickadee/buffer.scm: New file.
* Makefile.am (SOURCES): Add it.
* .dir-locals.el: Add indent rules for with-buffer and
with-current-buffer.
* examples/buffer.scm: New file.
* doc/api.texi (Buffers): Add docs.
Diffstat (limited to 'examples/buffer.scm')
-rw-r--r-- | examples/buffer.scm | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/examples/buffer.scm b/examples/buffer.scm new file mode 100644 index 0000000..4712ea4 --- /dev/null +++ b/examples/buffer.scm @@ -0,0 +1,33 @@ +(use-modules (chickadee) + (chickadee buffer) + (chickadee math vector) + (chickadee render font) + (chickadee render sprite) + (chickadee render texture) + (chickadee scripting) + (oop goops)) + +(define-class <splash-screen> (<buffer>) + (chickadee #:accessor chickadee #:init-value #f)) + +(define-method (start (splash <splash-screen>)) + (set! (chickadee splash) (load-image "images/chickadee.png")) + (after 120 (replace-buffer! (make <main-menu>)))) + +(define-method (draw (splash <splash-screen>) alpha) + (draw-sprite (chickadee splash) (vec2 256.0 176.0))) + +(define-class <main-menu> (<buffer>) + (font #:accessor menu-font #:init-value #f)) + +(define-method (start (menu <main-menu>)) + (set! (menu-font menu) (load-font "fonts/good_neighbors_starling.xml"))) + +(define-method (draw (menu <main-menu>) alpha) + (draw-text (menu-font menu) "press any key to exit" (vec2 200.0 240.0))) + +(define-method (key-press (menu <main-menu>) key scancode modifiers repeat?) + (pop-buffer!)) + +(use-buffers! (make <splash-screen>)) +(run-game) |