diff options
-rw-r--r-- | game.scm | 70 |
1 files changed, 67 insertions, 3 deletions
@@ -1,4 +1,7 @@ -(use-modules (chickadee graphics texture) +(use-modules (chickadee graphics color) + (chickadee graphics font) + (chickadee graphics texture) + (chickadee graphics viewport) (chickadee math vector) (oop goops) (starling asset) @@ -8,17 +11,78 @@ (starling node-2d) (starling scene)) + +;;; +;;; Constants +;;; + (define window-width 1280) (define window-height 720) (define game-width 640) (define game-height 360) -(define-class <game> (<gui-scene>)) + +;;; +;;; Assets +;;; + +(define-asset dialog-box-texture (load-image "assets/images/dialog-box.png")) +(define-asset darkness (load-image "assets/images/darkness.png")) +(define-asset room-background (load-image "assets/images/room.png")) +(define-asset monogram-font (load-font "assets/fonts/monogram_extended.ttf" 12)) + + +;;; +;;; Text Box +;;; + +(define-class <text-box> (<widget>) + (text #:accessor text #:init-keyword #:text #:init-value "" #:watch? #t)) + +(define-method (apply-theme (text-box <text-box>)) + (next-method) + (replace text-box + (make <label> + #:name 'text + #:rank 1 + #:font (font text-box) + #:text (text text-box) + #:position (vec2 6.0 + (- (height text-box) + (font-line-height + (asset-ref + (font text-box)))))))) + + +;;; +;;; Game +;;; + +(define-theme gui-theme + (<text-box> (background dialog-box-texture) + (font monogram-font))) + +(define-class <game> (<gui-scene>) + (state #:accessor state #:init-value #f)) + +(define-method (intro (game <game>)) + (set! (state game) 'intro) + (parameterize ((current-theme gui-theme)) + (attach-to game + (make <sprite> + #:texture darkness) + (make <text-box> + #:text "Hello" + #:width game-width + #:height 50.0)))) (define-method (on-boot (game <game>)) (set! (cameras game) (list (make <camera-2d> - #:resolution (vec2 game-width game-height))))) + #:resolution (vec2 game-width game-height) + #:viewport (make-viewport 0 0 window-width window-height + #:clear-color black)))) + (intro game)) (boot-kernel (make <kernel> #:window-config (make <window-config> |