summaryrefslogtreecommitdiff
path: root/examples/text.scm
diff options
context:
space:
mode:
Diffstat (limited to 'examples/text.scm')
-rw-r--r--examples/text.scm81
1 files changed, 77 insertions, 4 deletions
diff --git a/examples/text.scm b/examples/text.scm
index 3d2b3b5..d4d6489 100644
--- a/examples/text.scm
+++ b/examples/text.scm
@@ -1,9 +1,82 @@
(use-modules (chickadee)
+ (chickadee graphics text)
(chickadee math vector)
- (chickadee graphics font))
+ (chickadee scripting))
+
+(define start-time 0.0)
+(define avg-frame-time 16.0)
+(define stats-text "")
+(define stats-position (vec2 4.0 704.0))
+(define position (vec2 140.0 0.0))
+(define text
+ "This is the \"Are you tired of *this*?\" part of the infomercial. Read the next few paragraphs
+and picture me, in black and white, struggling to hold a large stack of boxes, all labeled
+\"software.\" I continue struggling to balance the boxes as you read. When you've reached the last
+paragraph of the section, I fall over, the boxes land on top of me and all over the floor, I'm
+covered in spaghetti, and in an exasperated voice I shout \"There's gotta be a better way!\"
+
+When setting up a new computer for software development, I want to go from `git clone` to `make` in
+as little time as possible (adjust that for your VCS and build system of choice.) In the old days,
+this meant manually installing the dependencies through the distro package manager. If things are
+organized, the project README will have a list of what is needed and it's not so bad. If things are
+less organized, it's a cycle of installing packages and running `./configure` or whatever until it
+succeeds. Hopefully none of the dependencies are too new to be found in the distro. And when
+working on multiple projects, hopefully there's no conflicts between the dependencies required for
+each of them, because your development environment is the entire system and there's no way to
+isolate different projects from each other.
+
+Of course, different programming languages provide their own sets of tools for managing multiple
+projects. Python has virtualenv, Ruby has rvm and bundler, Node has nvm and npm, etc. But their
+domain is restricted to only the dependencies for that language and their runtimes. A system
+package manager is needed to bootstrap their use.
+
+Nowadays it's \"just use Docker.\" Docker's take is that all this package management stuff is just
+too complicated. Instead, just create a disk image per project that encapsulates this hodgepodge of
+package managers and bespoke, artisinal, small-batch builds that gets run in isolation via Linux
+namespace magic. It works, of course, but I think Dockerfiles are clunky and the rather extreme
+level of isolation is usually unnecessary and makes things overly complicated for projects that need
+to interact with, say, the windowing system of the host computer. A lot of people are happy with
+Docker, though. Maybe you are, too. That's fine!
+
+What I really want to say is \"Computer, provision a development environment containing Guile 3,
+SDL2, make, and texinfo!\" and have Majel Barrett-Roddenberry tell me that all of those things have
+been made available to me on my host system. No container, no virtual machine. It shouldn't matter
+if I have Guile 2 installed system-wide, Guile 3 should still be what's used in the context of the
+project. This is how Guix works and it's very good and cool and I'm going to tell you all about how
+I use it."
+ ;; "The quick brown fox jumps over the lazy dog.\nFive hexing wizard bots jump quickly."
+ )
+
+(define (stats-message)
+ (format #f "fps: ~1,2f"
+ (/ 1.0 avg-frame-time)))
+
+(define (load)
+ (script
+ (forever
+ (sleep 60)
+ (set! stats-text (stats-message)))))
(define (draw alpha)
- (draw-text "The quick brown fox jumps over the lazy dog.\nFive hexing wizard bots jump quickly."
- (vec2 140.0 240.0)))
+ (draw-text text position)
+ (draw-text stats-text stats-position)
+ (let ((current-time (elapsed-time)))
+ (set! avg-frame-time
+ (+ (* (- current-time start-time) 0.1)
+ (* avg-frame-time 0.9)))
+ (set! start-time current-time)))
+
+(define (update dt)
+ (update-agenda 1))
+
+(define (key-press key modifiers repeat?)
+ (when (eq? key 'q)
+ (abort-game)))
-(run-game #:draw draw)
+(run-game #:draw draw
+ #:key-press key-press
+ #:load load
+ #:update update
+ #:window-title "text rendering"
+ #:window-width 1280
+ #:window-height 720)