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

  1. struct InitData {
  2. ushort sprite;
  3. ushort frame;
  4. ushort tileset;
  5. ushort clut;
  6. ushort info_idx;
  7. };


Sprite Data

WIP

  1. struct Sprite {
  2. Frame* frames[];
  3. };

  4. struct Frame {
  5. ushort num_parts;
  6. SpritePart parts[num_parts];
  7. };

  8. struct SpritePart {
  9. ushort flags;
  10. short offset_x;
  11. short offset_y;
  12. ushort width;
  13. ushort height;
  14. ushort clut_offset;
  15. ushort tileset_offset;
  16. ushort texture_start_x;
  17. ushort texture_start_y;
  18. ushort texture_end_x;
  19. ushort texture_end_y;
  20. };