Sprites
This page details how sprites are stored and referenced within the game.
Overview
Each Sprite is composed of one or more frames of animation.
Each Frame is composed of one or more sprite parts (images) that are arranged relative to the entity's position.
Each Sprite Part is a collection of data that dictates the position, size, reflection, and other properties of the image.
Below is a visual example of how a sprite is composed.
-
Sprite (Warg)
- ...
-
Frame [7]
- num_parts (7)
-
Sprite Part [0]
- offset_x (-49)
- offset_y (-19)
- ...
-
Sprite Part [1]
- offset_x (-33)
- offset_y (-27)
- ...
-
Sprite Part [2]
- offset_x (36)
- offset_y (-9)
- ...
-
Sprite Part [3]
- offset_x (13)
- offset_y (-15)
- ...
-
Sprite Part [4]
- offset_x (-16)
- offset_y (-7)
- ...
-
Sprite Part [5]
- offset_x (-29)
- offset_y (-25)
- ...
-
Sprite Part [6]
- offset_x (-29)
- offset_y (9)
- ...
- ...
These images are then added to an ordering table to be drawn.
Each sprite part is drawn in the order that it appears in the ordering table, with the first entry being drawn first.
To prevent each part from being overwritten, the sprite parts must be drawn in reverse order.
Doing so results in the following image:
Initialization Data
WIP
- struct InitData {
- ushort sprite;
- ushort frame;
- ushort tileset;
- ushort clut;
- ushort info_idx;
- };
Sprite Data
WIP
- struct Sprite {
- Frame* frames[];
- };
- struct Frame {
- ushort num_parts;
- SpritePart parts[num_parts];
- };
- struct SpritePart {
- ushort flags;
- short offset_x;
- short offset_y;
- ushort width;
- ushort height;
- ushort clut_offset;
- ushort tileset_offset;
- ushort texture_start_x;
- ushort texture_start_y;
- ushort texture_end_x;
- ushort texture_end_y;
- };