trip logs / gnuvola


Trip Log 2022-01-16 h01 -- Hooray! Part 2

In Part 2 of the Hooray! series, we look at a patch that adds window creation.  So now we have something to look at (maybe not much, but it's a start).  Without further ado, here's the patch in its entirety: 

     1  commit 0c5d5a81db7f0694d584999dd4675a45f8a212f4
     2  Author: Thien-Thi Nguyen <ttn@gnuvola.org>
     3  Date:   2022-01-15 18:57:36 -0500
     4
     5      Add window creation
     6
     7      * hooray.scm: Import SRFI 11 ‘let-values’.
     8      <top-level>: Add call to check ‘video-cmf’; set window caption.
     9      (TILE-EDGE-LENGTH): New constant.
    10      <top-level>: Add call to create square window;
    11      add call to wait a moment before quitting.
    12  ---
    13   hooray.scm | 15 ++++++++++++++-
    14   1 file changed, 14 insertions(+), 1 deletion(-)
    15
    16  diff --git a/hooray.scm b/hooray.scm
    17  index 11d7036..f8572ed 100644
    18  --- a/hooray.scm
    19  +++ b/hooray.scm
    20  @@ -17,15 +17,28 @@
    21
    22   ;; Usage: guile -s hooray.scm
    23   ;;
    24  -;; This currently does nothing special, except not crash (hopefully).
    25  +;; This opens a window, waits a moment, then exits.
    26  +;; The window has title "hooray!!!", maybe.
    27
    28   ;;; Code:
    29
    30   (use-modules
    31  + ((srfi srfi-11) #:select (let-values))
    32    ((sdl sdl) #:prefix SDL:))
    33
    34   (SDL:init 'video)
    35
    36  +(let-values (((cap mem fmt) (SDL:video-cmf)))
    37  +  (and (memq 'wm-available cap)
    38  +       (SDL:set-caption "hooray!!!")))
    39  +
    40  +(define TILE-EDGE-LENGTH 64)
    41  +
    42  +(SDL:set-video-mode (* 5 TILE-EDGE-LENGTH)
    43  +                    (* 5 TILE-EDGE-LENGTH)
    44  +                    32)
    45  +
    46  +(SDL:delay 420)
    47   (exit (SDL:quit))
    48
    49   ;;; hooray.scm ends here

(Again, this is basically “git show” output piped through “cat -n”, then untabified.)  The mechanics of the patch are evident in the change description and the resulting Commentary, so we'll gloss over that.  Instead, let's take a look at the scheme.png file that you downloaded following along the series Introduction (along w/ the PipeWalker tarball, remember?). 

In scheme.png, we see in the top half three rows of eight columns of 64x64 pixel squares.  These hold the tiles we will use in our animation.  There is one tile that is special: the so called ‘win’ tile is only 32x32 pixels.  We'll get to that later. 

So, that explains the constant on line 40 of the patch.  But why 5?  The answer is simple: This is not a full-blown emulation of the game, only the “hooray!” animation portion.  The plan is to place a ‘rec-1’ (i.e., “receiver on”) tile in the middle and have all the ‘win’ sprites flowing out of it. 

Speaking of which, I hope you've been playing PipeWalker and trying out all the themes.  The animation is, expectedly, the same for each theme, only the particular images change.  Here are the aspects of the animation that we want address, for a good emulation: 

* PipeWalker fg behavior (to reproduce if possible)
  - [ ] starts near top of center tile
  - [ ] mostly upward velocity
  - [ ] rotates clockwise slightly
  - [ ] starts smaller than 32x32
  - [ ] grows quickly
  - [ ] non synchronized (all aspects)
  - [ ] fades to transparent

(This is a fragment of an Org mode file that I use to organize these trip logs.)  The “fg” stands for “foreground”.  We'll get to that in due time. 


Copyright (C) 2022 Thien-Thi Nguyen