Patch:Vorticons Sprite Parameters

From KeenWiki
Jump to navigation Jump to search

Vorticons Sprite Parameters describe the various parameters all sprites in Keen Vorticons have. These range from clipping and speed to what image to use. A number of diverse parameters with various effects are summarized here. A related topic is Patch:Galaxy Sprite Parameters.


Sprite Structure

This is how the variables are stored, the structure of the sprite. Each variable is a two byte (word) value, except for the positioning variables, sprite hitbox and which are four byte (dword) values. Several of these values are not at present well known and information on them likely to be wrong.

Int	Function
$00	Object type
$02	Sprite active type
$04	X-position in level
$08	Y-position in level
$10-18	Sprite hitbox x1,y1 and x2,y2 in map units
$1C	X direction
$1E	Y direction
$20	X change in position per frame
$22	Y change in position per frame
$24     Sprite strength
$26     Misc variable A
$28     Current sprite image
$2A     Frame timer (Animation speed)
$2C     Misc variable B
$2E     Misc variable C (Seems to store the old speed (i.e. when keen jumps he pauses, then he continues with old speed))
$30     Misc variable D (If 0 then Keen will check for solid ground)
$32     Pointer to sprite's current behavior
$34     Pointer to sprite's current collision


Metasprite structure

Related to sprites are Metapsprites (Also known as 'bodies') which are similar, except they are always active (When they are offscreen they continue to function.) and they are somewhat simpler, lacking things like an animation (Instead they have a map tile.) These are used for things like opening doors, the falling block and the Mangling Machine. Their structure is somewhat shorter and simpler.

$00	X-position in level
$04	Y-position in level
$08	Object type
$0A    Variant
$0C    Horizontal direction (if needed)
$0E    Vertical direction (If needed)
$10    Misc variable
$12    Misc variable
$14    Misc variable
$16    Misc variable
$18    Misc variable
$1A    Misc variable
$1C    Misc variable
$1E    Misc variable
$20    Misc variable
$22    Sprite behavior


Game offsets

Each game uses a different offset which is added to the sprite variable involved when it is checked or changed. For example,changing a sprite's animation in Keen 2 to $0064W requires the following string: $C7 $06 $96E8W $0064W. Here the animation variable $28 is added to the game's offset. The offset for each game is as follows:

Keen 1: $8220W
Keen 2: $96C0W
Keen 3: $9910W


Variable functions

These are the functions of each variable in the game, as currently understood.


Object type

This is the sprite type which is used predominantly in sprite collisions to tell an object what kind of object (Keen, Keen's shot...) it is colliding with. In general each different kind of enemy will have its own object type, though few of them are strictly needed. This results in about 15 object types per game.


Sprite activity

This variable controls whether a sprite continues to function when Keen can't see it. If the value is 2 then the sprite will always be active. This uses more memory but is needed for sprites that must move on and off screen (Like moving platforms. Most sprites use a value of 1, which means they stop functioning when three or so tiles offscreen. A value of 0 results in a sprite ceasing function the very instant it is offscreen. (Dead sprites have this value, as do Ice cubes.


X/Y position

This is the current location of the sprite in the level, in map units (1/256th of a pixel.) This value is affected by many other variables. Changes to it are responsible for all sprite movement.


Hitbox

The sprite's hitbox; the area that responds to sprite and tile collisions is kept track of in both map units and tiles, as well as the horizontal middle of the hitbox. These are best not interfered with.


Velocity

These variables also change the sprite position, but do not depend on animation. Such movement is smooth and is used for example for falling things The main difference is that these values are applied every tic of game time, instead of every sprite frame. It too depends on direction.


Direction

This is the horizontal and vertical direction the sprite is facing. Sprites can face left\down, neither or up\right, with values of -1, 0 and +1 respectively. This value controls what direction the sprite moves in, as well as what graphic it uses. (See above.)


Strength

When a sprite is harmed this value will decrease by 1. When it is zero the sprite will execute its stunned code.


Temporary\Misc variables

These store temporary variables used for various things but not, as a rule, by sprites in general.


Timer

In a broad sense this is the animation speed; it is how long the sprite will spend on its current frame before proceeding to the next frame.


Graphic

This is the graphic (frame) drawn to represent the sprite. It is what the player sees. Usually when it is changed the sprite's hitbox is also altered to the one used by the graphic, but this is not strictly necessary.


Current behavior

This is a pointer to the code the sprite is using for its general behavior. This is checked once every game loop and the requisite code run.


Current collision

This is a pointer to the code the sprite is using for its collision with other sprites. This is checked every time one sprite touches another, and the requisite code run.


Variant

This is used by metasprites to distinguish one kind from another. It is not the metasprite type, but something the game will use to turn a number of very similar metasprites into more different ones. As an example, the Ice canons come in four kinds, identical except for their firing direction. They are given different firing directions depending on their variation.


Default values

Several variables have 'default values' used by sprites if a different value is not set. Sprite activity is 1 by default, All other values are zero. Map position is set when the sprite is created and is close to where it is placed in the map. (The vertical position is often adjusted a few pixels.)


Changing values of variables in game

There are two ways to change a sprite variable. The first is to set that variable when the sprite is being spawned. The second is to alter that variable when the sprite is running. Both are different, unlike in Galaxy and Dreams.

When setting a variable during sprite spawning variables are changed using a 5 byte string, $C7 $44 $xx $yyyyW, where $xx is the value to change and $yyyyW is the value to change it to. So for example to set a sprite's strength (Int 24) to 10 the string $C7 $44 $24 $000AW is used. The only exception is object type, which uses the string $C7 $04 $yyyyW (Since it is int 0.)

When altering a value a different string is used, that differs between games as follows:

Keen 1: $C7 $06 $8220W + x $yyyyW
Keen 2: $C7 $06 $96C0W + x $yyyyW
Keen 3: $C7 $06 $9910W + x $yyyyW

So to do the same thing as our above example, but change the sprite strength instead of set it, we use the string $C7 $06 $44 $82 $000AW in Keen 1, but $C7 $06 $34 $99 $000AW in Keen 3.

When a variable is changed it affects only the one object running that code. (For example only one Vorticon tends to search (Change its action.) at a time.