Porytiles
Loading...
Searching...
No Matches
porytiles::Animation< PixelType > Class Template Reference

A complete tileset animation with name, configuration, and frame data. More...

#include <animation.hpp>

Public Member Functions

 Animation ()=default
 
 Animation (std::string name)
 
 Animation (std::string name, AnimParams params)
 
const std::string & name () const
 
const AnimParamsparams () const
 
void params (AnimParams params)
 
bool has_key_frame () const
 Checks if this animation has a key frame set.
 
const AnimFrame< PixelType > & key_frame () const
 Returns the key frame of this animation.
 
void key_frame (AnimFrame< PixelType > key_frame)
 
const std::map< std::string, AnimFrame< PixelType > > & frames () const
 
std::map< std::string, AnimFrame< PixelType > > & frames ()
 
std::vector< AnimFrame< PixelType > > frames_values () const
 
bool has_frames () const
 Checks if this animation has any frames.
 
std::size_t frame_count () const
 Returns the number of frames in this animation.
 
bool has_frame (const std::string &frame_name)
 
const AnimFrame< PixelType > & frame_for_name (const std::string &frame_name) const
 Returns the frame with the specified name.
 
void put_frame (const std::string &name, AnimFrame< PixelType > frame)
 Adds a frame to this Animation frame map.
 
AnimFrame< PixelType > composite_frame (const PixelType &extrinsic_transparency) const
 Returns the "composite" frame for this animation.
 

Detailed Description

template<SupportsTransparency PixelType>
class porytiles::Animation< PixelType >

A complete tileset animation with name, configuration, and frame data.

Animation represents a full animation definition for a tileset, combining:

  • A unique name identifying the animation (e.g., "flower", "water", "waterfall")
  • Configuration parameters (AnimParams) controlling timing and VRAM placement
  • An optional key frame (for Porytiles-format animations)
  • Frame data (map of AnimFrame) containing the actual tile pixels

In addition to the standard frames, there is a special "key frame" that appears in tiles.png. The GBA game engine uses the other frames (stored as separate .4bpp files) to animate by swapping tile data in VRAM at runtime.

The template parameter determines the pixel format:

Template Parameters
PixelTypeThe pixel type for animation frame tiles; must satisfy SupportsTransparency concept

Definition at line 78 of file animation.hpp.

Constructor & Destructor Documentation

◆ Animation() [1/3]

template<SupportsTransparency PixelType>
porytiles::Animation< PixelType >::Animation ( )
default

◆ Animation() [2/3]

template<SupportsTransparency PixelType>
porytiles::Animation< PixelType >::Animation ( std::string  name)
inlineexplicit

Definition at line 82 of file animation.hpp.

◆ Animation() [3/3]

template<SupportsTransparency PixelType>
porytiles::Animation< PixelType >::Animation ( std::string  name,
AnimParams  params 
)
inline

Definition at line 84 of file animation.hpp.

Member Function Documentation

◆ composite_frame()

template<SupportsTransparency PixelType>
AnimFrame< PixelType > porytiles::Animation< PixelType >::composite_frame ( const PixelType &  extrinsic_transparency) const
inline

Returns the "composite" frame for this animation.

The "composite" frame for an Animation is a special, artificially constructed frame where each constituent subtile contains all colors across all AnimFrames (including the key frame, if present) for the given subtile index. This is essential: since animation tiles are dynamic but the palette index is fixed, the palette packer needs to know all possible colors that could appear in a given 8x8 animation tile region at any point in the animation. The composite frame's pixel arrangement is arbitrary and shouldn't be relied upon for meaningful information.

If a key frame is present, its tile count determines the composite frame size. Otherwise, the first regular frame's tile count is used. This allows animations without key frames to support manual animation linking workflows.

Parameters
extrinsic_transparencyThe extrinsic transparency color to use when filtering pixels
Precondition
has_key_frame() or has_frames() must return true
Postcondition
Each composite tile within the frame will have <= 15 unique colors.
Returns
A composite frame for this Animation.

Definition at line 220 of file animation.hpp.

◆ frame_count()

template<SupportsTransparency PixelType>
std::size_t porytiles::Animation< PixelType >::frame_count ( ) const
inline

Returns the number of frames in this animation.

Returns
The frame count

Definition at line 164 of file animation.hpp.

◆ frame_for_name()

template<SupportsTransparency PixelType>
const AnimFrame< PixelType > & porytiles::Animation< PixelType >::frame_for_name ( const std::string &  frame_name) const
inline

Returns the frame with the specified name.

Parameters
frame_nameThe frame name
Precondition
index must be less than frame_count()
Returns
Reference to the frame at the specified index

Definition at line 181 of file animation.hpp.

◆ frames() [1/2]

template<SupportsTransparency PixelType>
std::map< std::string, AnimFrame< PixelType > > & porytiles::Animation< PixelType >::frames ( )
inline

Definition at line 139 of file animation.hpp.

◆ frames() [2/2]

template<SupportsTransparency PixelType>
const std::map< std::string, AnimFrame< PixelType > > & porytiles::Animation< PixelType >::frames ( ) const
inline

Definition at line 134 of file animation.hpp.

◆ frames_values()

template<SupportsTransparency PixelType>
std::vector< AnimFrame< PixelType > > porytiles::Animation< PixelType >::frames_values ( ) const
inline

Definition at line 144 of file animation.hpp.

◆ has_frame()

template<SupportsTransparency PixelType>
bool porytiles::Animation< PixelType >::has_frame ( const std::string &  frame_name)
inline

Definition at line 169 of file animation.hpp.

◆ has_frames()

template<SupportsTransparency PixelType>
bool porytiles::Animation< PixelType >::has_frames ( ) const
inline

Checks if this animation has any frames.

Returns
True if the animation has at least one frame, false otherwise

Definition at line 154 of file animation.hpp.

◆ has_key_frame()

template<SupportsTransparency PixelType>
bool porytiles::Animation< PixelType >::has_key_frame ( ) const
inline

Checks if this animation has a key frame set.

Returns
True if the key frame has been set, false otherwise

Definition at line 106 of file animation.hpp.

◆ key_frame() [1/2]

template<SupportsTransparency PixelType>
const AnimFrame< PixelType > & porytiles::Animation< PixelType >::key_frame ( ) const
inline

Returns the key frame of this animation.

The key frame is a special frame of the animation and is the frame whose tiles are stored in tiles.png. All other frames are stored as separate .4bpp files and loaded dynamically by the game engine.

Precondition
has_key_frame() must return true
Returns
Reference to the keyframe

Definition at line 121 of file animation.hpp.

◆ key_frame() [2/2]

template<SupportsTransparency PixelType>
void porytiles::Animation< PixelType >::key_frame ( AnimFrame< PixelType >  key_frame)
inline

Definition at line 129 of file animation.hpp.

◆ name()

template<SupportsTransparency PixelType>
const std::string & porytiles::Animation< PixelType >::name ( ) const
inline

Definition at line 86 of file animation.hpp.

◆ params() [1/2]

template<SupportsTransparency PixelType>
const AnimParams & porytiles::Animation< PixelType >::params ( ) const
inline

Definition at line 91 of file animation.hpp.

◆ params() [2/2]

template<SupportsTransparency PixelType>
void porytiles::Animation< PixelType >::params ( AnimParams  params)
inline

Definition at line 96 of file animation.hpp.

◆ put_frame()

template<SupportsTransparency PixelType>
void porytiles::Animation< PixelType >::put_frame ( const std::string &  name,
AnimFrame< PixelType >  frame 
)
inline

Adds a frame to this Animation frame map.

Parameters
nameThe frame name
frameThe frame to add

Definition at line 195 of file animation.hpp.


The documentation for this class was generated from the following file: