diff options
author | Ricardo Wurmus <rekado@elephly.net> | 2018-07-25 10:32:16 +0200 |
---|---|---|
committer | Ricardo Wurmus <rekado@elephly.net> | 2018-07-27 17:15:48 +0200 |
commit | ce22c1916efd19c184b35146f81fd5dfee39909b (patch) | |
tree | 5a4daf687e1783f287f07bbde7e16255c987b58a | |
parent | f3dd149c6bd081670f20649734d11f0ee8d3eddc (diff) |
Use readable font everywhere.
-rw-r--r-- | scenes/death.scm | 15 | ||||
-rw-r--r-- | scenes/game.scm | 8 | ||||
-rw-r--r-- | scenes/intro.scm | 24 |
3 files changed, 27 insertions, 20 deletions
diff --git a/scenes/death.scm b/scenes/death.scm index 29d006f..26b0dff 100644 --- a/scenes/death.scm +++ b/scenes/death.scm @@ -234,11 +234,16 @@ void main (void) { (make <node-2d> #:children (list death - (make <label> - #:name 'press-enter - #:font death-font - #:text "Press any key to quit." - #:position (vec2 72.0 20.0)) + (let ((text "Press any key to quit.") + (font death-font)) + (make <label> + #:font font + #:text text + #:position + (let ((width (font-line-width (asset-ref font) text))) + (vec2 (- (/ %width 2) + (/ width 2)) + 30.0)))) (make <node-2d> #:name 'credits-container #:origin (vec2 (- (/ %width 2)) diff --git a/scenes/game.scm b/scenes/game.scm index efaafe4..aeb699c 100644 --- a/scenes/game.scm +++ b/scenes/game.scm @@ -62,10 +62,6 @@ (tile-map #:accessor tile-map #:init-form test-map)) (define-asset game-font - (load-tile-font "assets/fonts/bubblemad_8x8.png" 8 8 - " !\"©_%❤'()*+,-./0123456789:←<=>?@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")) - -(define-asset talk-font (load-font "assets/fonts/good_neighbors_starling.xml")) (define (start-position game name) @@ -328,7 +324,7 @@ be executed; if so, perform the action." (define* (render-text bubble text #:key (y-offset 0) (suffix '-text)) "Fill the bubble with lines of text. Return the number of lines." - (let ((lines (arrange-text text (asset-ref talk-font) + (let ((lines (arrange-text text (asset-ref game-font) #:margin 4.0))) (for-each (lambda (line i) (attach bubble (make <label> @@ -336,7 +332,7 @@ be executed; if so, perform the action." (string->symbol (number->string i)) suffix) - #:font talk-font + #:font game-font #:text line #:position (vec2 4.0 (- 65 y-offset (* %line-height i)))))) diff --git a/scenes/intro.scm b/scenes/intro.scm index 285f0a3..0592eed 100644 --- a/scenes/intro.scm +++ b/scenes/intro.scm @@ -24,15 +24,15 @@ #:use-module (engine node-2d) #:use-module (engine scene) #:use-module (engine shell) + #:use-module (config) #:use-module (scenes game) #:use-module (oop goops) #:export (<intro>)) (define-class <intro> (<scene>)) -(define-asset intro-font - (load-tile-font "assets/fonts/bubblemad_8x8.png" 8 8 - " !\"©_%❤'()*+,-./0123456789:←<=>?@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")) +(define-asset game-font + (load-font "assets/fonts/good_neighbors_starling.xml")) (define texts '("\ @@ -63,17 +63,23 @@ to dry.")) (define-method (populate (intro <intro>)) (cons - (make <label> - #:name 'press-enter - #:font intro-font - #:text "Press enter to start." - #:position (vec2 72.0 50.0)) + (let ((text "Press enter to start.") + (font game-font)) + (make <label> + #:name 'press-enter + #:font font + #:text text + #:position + (let ((width (font-line-width (asset-ref font) text))) + (vec2 (- (/ %width 2) + (/ width 2)) + 30.0)))) (let* ((text (list-ref texts (random (length texts)))) (parts (string-split text #\newline))) (map (lambda (part i) (make <label> #:name 'welcome - #:font intro-font + #:font game-font #:text part #:position (vec2 16.0 (- 150.0 (* 12 i))))) parts (iota (length parts)))))) |