summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2018-07-24 23:02:45 +0200
committerRicardo Wurmus <rekado@elephly.net>2018-07-27 17:15:47 +0200
commit5837c04a436a64ff75aa5acdbf04a5dc85cbb604 (patch)
tree0e604699d19e0659817b0d185ff366da5797b1d7
parent61e01fd86d2e1a8e50a1f3609be6b02cd127e79e (diff)
Use more readable font.
-rw-r--r--config.scm4
-rw-r--r--scenes/game.scm16
-rw-r--r--utils.scm13
3 files changed, 18 insertions, 15 deletions
diff --git a/config.scm b/config.scm
index 1895202..d52ae55 100644
--- a/config.scm
+++ b/config.scm
@@ -24,5 +24,5 @@
(define %width 320)
(define %height 240)
-(define %line-height 10.0)
-(define %message-margin 3.0)
+(define %line-height 12.5)
+(define %message-margin 4.0)
diff --git a/scenes/game.scm b/scenes/game.scm
index fbe32be..efaafe4 100644
--- a/scenes/game.scm
+++ b/scenes/game.scm
@@ -65,6 +65,9 @@
(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)
"Look up the start position for an object with the given NAME in the
map's object layer."
@@ -158,8 +161,8 @@ map's object layer."
(attach bubble
(make <filled-rect>
#:name 'dialog-selection-indicator
- #:region (make-rect 0.0 0.0 10 10)
- #:position (vec2 0 40)
+ #:region (make-rect 0.0 0.0 5 10)
+ #:position (vec2 0 65)
#:color region)))
(+ lines
(render-text bubble text
@@ -325,17 +328,18 @@ 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)))
+ (let ((lines (arrange-text text (asset-ref talk-font)
+ #:margin 4.0)))
(for-each (lambda (line i)
(attach bubble (make <label>
#:name (symbol-append 'dialog-line-
(string->symbol
(number->string i))
suffix)
- #:font game-font
+ #:font talk-font
#:text line
#:position (vec2 4.0
- (- 40 y-offset (* %line-height i))))))
+ (- 65 y-offset (* %line-height i))))))
lines
(iota (length lines)))
(length lines)))
@@ -408,7 +412,7 @@ be executed; if so, perform the action."
#:children
(list (make <filled-rect>
#:name 'text-bubble-box
- #:region (make-rect 0.0 0.0 %width 50)
+ #:region (make-rect 0.0 0.0 %width 80)
#:position (vec2 0 0)
#:rank -10 ; background
#:color (make-color 0 0 0 0.5))))))))
diff --git a/utils.scm b/utils.scm
index 670a9af..d249e86 100644
--- a/utils.scm
+++ b/utils.scm
@@ -16,13 +16,13 @@
;;; <http://www.gnu.org/licenses/>.
(define-module (utils)
+ #:use-module (chickadee render font)
#:use-module (srfi srfi-1)
#:use-module (ice-9 match)
#:use-module (config)
#:export (arrange-text))
-(define* (arrange-text text #:key
- (character-width 8.0)
+(define* (arrange-text text font #:key
(margin 0.0)
(max-width %width))
"Take the string TEXT and split it at spaces so that it fits in the
@@ -30,13 +30,12 @@ given MAX-WIDTH. Return a list of lines."
(match (fold (lambda (chunk acc)
(match acc
((#:width width #:result (and (current-line . tail) lines))
- (let* ((len (+ 1 (string-length chunk)))
- (chunk-width (* len character-width))
- (new-width (+ chunk-width width)))
+ (let* ((new-line (string-append current-line " " chunk))
+ (new-width (font-line-width font new-line)))
(if (< (+ new-width margin) max-width)
`(#:width ,new-width
- #:result ,(cons (string-append current-line " " chunk) tail))
- `(#:width ,chunk-width
+ #:result ,(cons new-line tail))
+ `(#:width ,(font-line-width font chunk)
#:result ,(cons chunk lines)))))))
'(#:width 0 #:result (""))
(string-tokenize text))