Graphical Window Animation
version 3 by Erik Temple
Section: Some Details and Fine Points
Animations are drawn using the current graphics drawing rule (see the Simple Graphical Window extension). When an animation ends, it returns control of the window to the currently shown picture as defined in the source. (If you are also using Emily Short's Location Images extension, this will be the current room illustration.) If the currently shown picture is undefined, the behavior of the window will depend on which rule is defined (the default rule fills the window with black). We can, of course, set any image to display on termination of the animation by placing the following line in the source directly after the "animate" phrase:
now the currently shown picture is (the chosen image)
This might be useful if, for example, we want to ensure that the last frame of the animation persists on screen until any other screen-drawing rules are invoked (for example, by moving between rooms or by looking).
It is important to emphasize that animations, once triggered, are advanced independently of most rules that do not affect the Glulx timer (the glulx timed activity rules defined by Emily Short's Glulx Entry Points extension, on which Graphical Window Animation depends). Thus, we should not expect that this code block
now the current reel is the sleigh bells reel;
animate the current reel at 10 fps;
now the current reel is the slay bells reel;
animate the current reel at 10 fps.
will display the two animations, one after the other. Rather, the second animation is triggered immediately after the first, and thus supersedes it. The commands that alter running animations are thus really only of use on looping animations, because we can write our code to be sure that these are called while the animation is still running.
If we want to ensure that the player sees the full animation before the game continues, we can pause all input and output with the phrase
wait for animation to end
This will pause the game until the animation ends, or until the player presses the ESC key. This phrase will have no effect when used with looping animations.
Finally, the author can test conditions surround the animation in progress using the following descriptions:
when animation occurs
the current reel
the current frame
"When animation occurs" is used to inquire whether an animation is currently ongoing. We can also ask what reel is the current reel (e.g., "if the current reel is the reel of destruction"), and what frame is the current frame ("if the current frame is 7"). The latter could be used, for example, to trigger another event (such as a playing a sound) when a given frame is reached. For the most part, these should be used in the course of rules in the glulx timed activities and glulx picture selection rulebooks (defined in Emily Short's Glulx Entry Points).