summaryrefslogtreecommitdiff
path: root/scenes/game.scm
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2018-07-21 23:02:51 +0200
committerRicardo Wurmus <rekado@elephly.net>2018-07-27 17:15:47 +0200
commit2be5bb221bae718f0625569517178a66892ac14a (patch)
treed0b9d846d33edc7d5827ece02e6b0e5045c87c5b /scenes/game.scm
parentd9765a2508aacb3dd3aac6f02b6185302adba7d3 (diff)
Move arrange-text to utils module.
Diffstat (limited to 'scenes/game.scm')
-rw-r--r--scenes/game.scm23
1 files changed, 1 insertions, 22 deletions
diff --git a/scenes/game.scm b/scenes/game.scm
index a51fd18..4ae862d 100644
--- a/scenes/game.scm
+++ b/scenes/game.scm
@@ -37,6 +37,7 @@
#:use-module (characters)
#:use-module (characters lorenzo)
#:use-module (characters reaper)
+ #:use-module (utils)
#:use-module (config)
#:export (game))
@@ -123,28 +124,6 @@ map's object layer."
#:name 'stats #:object player
#:position (vec2 10.0 (- %height 10.0))))))
-(define* (arrange-text text #:key
- (character-width 8.0)
- (margin 0.0)
- (max-width %width))
- "Take the string TEXT and split it at spaces so that it fits in the
-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)))
- (if (< (+ new-width margin) max-width)
- `(#:width ,new-width
- #:result ,(cons (string-append current-line " " chunk) tail))
- `(#:width ,chunk-width
- #:result ,(cons chunk lines)))))))
- '(#:width 0 #:result (""))
- (string-tokenize text))
- ((#:width _ #:result lines)
- (reverse lines))))
-
(define* (collides? player game #:key (layer "collision"))
(let* ((pos (position player))
(offset (origin game))