summaryrefslogtreecommitdiff
path: root/examples/buffer.scm
diff options
context:
space:
mode:
Diffstat (limited to 'examples/buffer.scm')
-rw-r--r--examples/buffer.scm33
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)