"Metanimations" and You: Understanding the main game display loop.
Zac Adam-MacEwen edited this page 2025-03-17 15:51:00 -03:00

Currently, the operation of the main_game display loop is to do the following simplified operation:

  • interrogate the game state object to determine what species is active.
  • Based on that data, determine the appropriate character set to use. This is the stage's .animation property.
  • Pull a metanimation from a global array, determining what the active frame should be.
  • Using the metanimation, draw the characters for the species-specific animation onto the display.

These "metanimations" are provided in /lib/scenes/main_game/metanimations.h and exposed to the cardbase as a persistent array of Metanimation structures. The following such structure describes the metanimation used for the egg stage of life:

Metanimation SCENES_metanimations[] = { // Parent array of metanimations exposed to other functions. Should contain one for each phase-of-life.
                                {//begin entry for the egg phase
                                 .phase_id = 0x00,
                                 .d = {
                                       {
                                        "--------",
                                        "--------",
                                        "---00---",
                                        "---00---",
                                        "--------",
                                        "--------"
                                       },
                                       {
                                        "--------",
                                        "--------",
                                        "---00---",
                                        "---00---",
                                        "--------",
                                        "--------"
                                       },
                                       {
                                        "--------",
                                        "--------",
                                        "---00---",
                                        "---00---",
                                        "--------",
                                        "--------"
                                       },
                                       {
                                        "--------",
                                        "--------",
                                        "---00---",
                                        "---00---",
                                        "--------",
                                        "--------"
                                       }
                                    }
                                }
};

Metanimations rely currently on a very simple syntax:

  • Each consists of four frames
  • Each frame is an array of 6 strings, one for each line of the playing field.
  • Each string is effectively an array of eight characters, each representing a 16x16 cell of the playing field.

The function that parses these strings will do the following while iterating over the strings in the current frame:

  • If the character is -, a blank space will be printed.
  • If the character is _, a blank space will be printed in full black (v 0.0.2 or later)
  • If the character is 0, the next character from the relevant species animation will be printed.
  • If the character is 1, the next character from the relevant species animation will be printed, as though the full animation has been mirrored horizontally (a left-facing design now faces right) (v 0.0.2 or later)
  • If the character is 2, the next character will be displayed in inverse color (v 0.0.2 or later)
  • If the character is 3, both 1 and 2 are applied (v 0.0.2 or later)
  • If the character is @, this will be printed as a blank space, but serve as the root for the status icons (v 0.5.0 and later)

These animations are referenced based on the stage.phase property, taking that value as the index from SCENES_metanimations to pull. This allows currently for only one metanimation per age of life.

Work is being done to consider applying the metanimations at the species level or allow for "variant metanimations" that may occasionally be dropped into. It is also likely that the metanimation characterset will be expanded to allow the use of indicators to state the character should be looking to the right or left in a particular frame, or otherwise alter the sprite of the character in question.