Patch:Sprite animations

From KeenWiki
Jump to: navigation, search

This page is a tutorial page on patching sprite animations. It contains information on what sprite animations are, how to patch them, and a list of the possible types for all Keen games. The sprite animation is not as simple as it first seems, there are two basic systems, Vorticons and Dreams\Galaxy. They will be considered in two sections.


In Vorticons a sprite's animations are divided into groups, one per sprite 'behavior' For example, the Yorp has a walking, searching, stunned and shot animation. The animation is set at the start of the behavior and consists of a starting animation and (optionally) the number of following frames to use and animation speed. As an example the following is the waking Yorp setup:

Patch: Keen 1
%patch $19E7 48  
#Looking around animation
%patch $19E4 3
#Frames used -1
%patch $19E0 5
#Animation speed

There are no restrictions on what image(s) may be used for a sprite, and even the number of graphics can be changed in some versions of ModKeen and Keengraph. The animation speed is the timing between animations, the larger it is, the slower something animates. Most speeds are 4 or 5. In this example animation frames 48-52 are used (Start frame + 3 following)

If a sprite needs left and right animations, both of these will be set at the behavior's start:

Patch: Keen 1
%patch $1993 52  
#Walking right
%patch $199B 54
#Walking left
%patch $19A5 1
#Frames used for both
%patch $19A1 4
#Animation speed


In Galaxy sprites are more versatile, complex and restricted. Each sprite action has its own animation. The left and right animations a sprite uses are given as two words, the first for when the sprite is facing left, the second for when it is facing right. (See sprite direction.) There are two limits on what values may be used, firstly the value must be a valid sprite chunk. The value used is chunk number, not sprite number, and the difference is important. Graphic chunks are used for many things, fonts, bitmaps, sprites and tiles. There is thus an arbitrary value added to the 'real' animation number:

Keen 4: +124
Keen 5: +102
Keen 6: ???
Keen D: ???

This applies mainly to ModKeen extracted graphics, since these name files by graphic type number, not chunk number, and other programs (Such as Keengraph) don't require this.

The second restriction is that an animation must be cached in the level or the game will crash with an 'uncached sprite' error.

When sprite animations are patched it is also advisable to keep in mind the animation speed. This controls how long the animation lasts. An example here makes Keen use the normal death animations for when he is killed while swimming:

Patch: Dead swimming Keen in Keen 4
%patch $2FB9E $00A2W $00A2W 
%patch $2FBA8 $0064W        
#Animation speed
%patch $2FBBC $00A3W $00A3W %patch $2FBC6 $0064W
#Animation speed

There are two special values to keep in mind. $0000W is used when the action isn't supposed to change whatever animation the sprite had last. It basically means 'Use whatever you're using now.' The value $FFFF (-1) is used when a sprite is invisible, but still there (such as the Babobba's cinder when it is blinking before finally being extinguished. Invisible sprites may still be able to interact with other sprites, but the invisibility can be useful.