pub struct MetatileDef {
pub size: (u8, u8),
pub tiles: Vec<MetatileCell>,
pub collision: Vec<CollisionCell>,
pub trigger: Option<TriggerDef>,
pub animation_group: Option<u8>,
pub z_offset: i8,
}Expand description
A metatile — a logical unit comprised of N×N tiles.
This is the JRPG engine generalization of Game Boy’s “block” concept (4×4 tiles = 16 bytes). Variable-size support enables use with other tile-based games (2×2, 3×3, …).
Fields§
§size: (u8, u8)Width and height in tiles, e.g. (4, 4) for GB blocks.
tiles: Vec<MetatileCell>The tiles that make up this metatile, stored in row-major order.
Must contain exactly size.0 * size.1 entries.
collision: Vec<CollisionCell>Per-cell collision, same dimensions as size. If collision.len()
differs from tile_count(), the engine should treat the whole
metatile uniformly (e.g. all cells inherit the first collision entry).
trigger: Option<TriggerDef>Optional trigger script that fires when the player interacts with or steps on this metatile.
animation_group: Option<u8>Optional animation group index — tiles inside the metatile animate in lockstep if they share the same group.
z_offset: i8Vertical render offset (pixels). Positive values render the
metatile lower on screen, useful for layered maps or floating
platforms. Default is 0.
Implementations§
Source§impl MetatileDef
impl MetatileDef
Sourcepub fn new(size: (u8, u8)) -> Self
pub fn new(size: (u8, u8)) -> Self
Creates an empty metatile of the given size.
All tiles default to tile ID 0 with no flips; all collision cells
are Passable. trigger, animation_group and z_offset are
initialised to their defaults.
§Panics
Panics if either dimension is 0.
Sourcepub fn tile_count(&self) -> usize
pub fn tile_count(&self) -> usize
Returns the total number of tiles in this metatile (size.0 * size.1).
Sourcepub fn from_gb_block(block_data: &[u8]) -> Self
pub fn from_gb_block(block_data: &[u8]) -> Self
Converts a 16-byte Game Boy .bst block into a 4×4 MetatileDef.
Each byte in block_data is a raw tile ID. Entries are placed in
row-major order (top-left to bottom-right). All collision cells
default to Passable.
§Panics
Panics if block_data does not contain exactly 16 bytes.
Trait Implementations§
Source§impl Clone for MetatileDef
impl Clone for MetatileDef
Source§fn clone(&self) -> MetatileDef
fn clone(&self) -> MetatileDef
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more