trip logs / gnuvola


Trip Log 2022-01-09 h08 -- Hooray! Introduction

I maintain Guile-SDL and am acutely aware of my limitations in the field where SDL is most used (games), not being a “hard-core” gamer.  Instead, I stick w/ Tetris and Go and occasionally wander out of the Emacs lifeboat to see what's swimming in the wild.  I recently found PipeWalker by Artem Senichev and have been enjoying it, especially the animation that happens when you complete a level — I like to think of it as the “hooray” animation.  This got me to thinking: Wouldn't it be nice if I could reproduce that animation using Guile-SDL?  While trying to do so, it also occurred to me: Now that the Contained Collections page is up, wouldn't it be nice to do a series of Trip Logs documenting my progress?  Kind of like the Indices Style Upgrade series but (much!) less tedious and (hopefully) much more fun?  Busking busy-ness begin! 

Part of the tediousness of the Indices Style Upgrade series is due to the long rambling prose style that really doesn't get to the point until the very end.  Well, dear reader, fear not — I have learned to write more concisely.  Promise!  In this series, I will stick to a simple format, posting a patch and reviewing it every week (usually during the weekends).  The goal is to have each Trip Log be an easy 10-minute read (plus time to play if you're following along and have Guile-SDL installed).  I don't know exactly how long the series will go, but I do know that it will end w/ another release of Guile-SDL, so maybe a month or two... 

So, in the spirit of moving things forward, here's what you should do if you want to follow along and get the maximum effect:  (1)  Install and play PipeWalker so you can see for yourself what we're trying to emulate.  (2)  Grab the PipeWalker source code (from sourceforge) as well as this handy scheme.png that doesn't seem to be in the tarball.  (I will be working w/ version 0.9.4 for the duration of the series.)  (3)  Install Guile-SDL and (if you're a speed freak) see if you can finish before the rest of us! 

OTOH, if that's too much of a bother, and you're already eyeing your watch to see if 10 minutes have passed, here's the first patch:

     1	commit 3a2f302f5117e45e5e51ac10df0e8533e12a41f2
     2	Author: Thien-Thi Nguyen <ttn@gnuvola.org>
     3	Date:   2022-01-09 02:53:56 -0500
     4
     5	    Add seed source code for ‘Hooray!’ Trip Log series.
     6
     7	    * hooray.scm: New file.
     8	---
     9	 hooray.scm | 31 +++++++++++++++++++++++++++++++
    10	 1 file changed, 31 insertions(+)
    11
    12	diff --git a/hooray.scm b/hooray.scm
    13	new file mode 100644
    14	index 0000000..11d7036
    15	--- /dev/null
    16	+++ b/hooray.scm
    17	@@ -0,0 +1,31 @@
    18	+;;; hooray.scm
    19	+
    20	+;; This program is free software; you can redistribute it and/or modify
    21	+;; it under the terms of the GNU General Public License as published by
    22	+;; the Free Software Foundation, either version 3 of the License, or
    23	+;; (at your option) any later version.
    24	+
    25	+;; This program is distributed in the hope that it will be useful,
    26	+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
    27	+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    28	+;; GNU General Public License for more details.
    29	+
    30	+;; You should have received a copy of the GNU General Public License
    31	+;; along with this program.  If not, see <https://www.gnu.org/licenses/>.
    32	+
    33	+;;; Commentary:
    34	+
    35	+;; Usage: guile -s hooray.scm
    36	+;;
    37	+;; This currently does nothing special, except not crash (hopefully).
    38	+
    39	+;;; Code:
    40	+
    41	+(use-modules
    42	+ ((sdl sdl) #:prefix SDL:))
    43	+
    44	+(SDL:init 'video)
    45	+
    46	+(exit (SDL:quit))
    47	+
    48	+;;; hooray.scm ends here

(This is ‘git show’ output, run through ‘cat -n’ to get the line numbers.)  I'm considering joining Patreon and letting people w/ “membership” have accesss to the (unannotated) patches and even the Git repo — would you be interested?  Please email me privately w/ your thoughts on the matter. 

As you might expect, this is very simple.  But anyway, we can review it.  Lots of boilerplate — that's the world we live in — but the core (lines 41-46) is easy to understand: Import the ‘(sdl sdl)’ module, prefixing all of its names with “SDL:”, followed by a call to ‘init’, specifying the ‘video’ subsystem, followed by a call to ‘quit’.  The return value of ‘quit’ is used as the ‘exit’ argument, as well. 

This does nothing useful, but (like the comment on line 37) not crash.  If you find it crashes for you, then by all means report the problem — that's a serious bug that needs to be investigated and fixed! 

OK, see you next week. 


Copyright (C) 2022 Thien-Thi Nguyen