summaryrefslogtreecommitdiff
path: root/examples/buffer.scm
blob: 4712ea47d9b6e8f2455a251cf5b72ac24fad25b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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)