spritesheet
FreeBodyEngine.core.tilemap.spritesheet
#
AnimatedSpritesheet(data, renderer)
#
Bases: TilemapSpritesheet
A spritesheet whose image index changes every frame (e.g. a looping
animation), so it's recomputed every frame (UpdateMode.FRAME).
Args: data: Spritesheet definition data. renderer: The tilemap's renderer, whose texture stack the paths are added to.
AutoSpritesheet(data, renderer)
#
Bases: TilemapSpritesheet
A spritesheet whose image index depends on a tile's neighbors (e.g.
auto-tiling edges/corners), so it's recomputed on every chunk update
(UpdateMode.CHUNK) rather than once.
Args: data: Spritesheet definition data. renderer: The tilemap's renderer, whose texture stack the paths are added to.
StaticSpritesheet(data, renderer)
#
Bases: TilemapSpritesheet
A spritesheet where each tile's image is fixed by its image_id alone
(no auto-tiling/animation), so its image index only needs computing once
per tile (UpdateMode.ONCE).
data: Spritesheet definition; data["paths"] is a list of
(key, path) pairs, keyed by image_id.
renderer: The tilemap's renderer, whose texture stack the paths are added to.
data = data
instance-attribute
#
get_image_id(key)
#
Looks up the image_id registered under key in data["paths"],
or -1 if key isn't found.
get_image_index(tile, neighbors)
#
Looks up tile's image index by its image_id alone; neighbors is unused.
get_name()
staticmethod
#
The type name spritesheet data uses to select this class (see Tilemap.add_spritesheet_type).
TilemapSpritesheet(data, renderer, update_mode=UpdateMode.NEVER)
#
Base class for a tilemap's image-lookup source: maps a tile's
image_id (and its neighbors, for auto-tiling) to an index into the
renderer's uploaded texture stack. Subclasses implement get_image_index,
_extract_paths, and update for a particular lookup strategy (static,
auto-tiled, animated).
Args:
data: The spritesheet definition data (as passed to Tilemap.create_spritesheet).
renderer: The tilemap's renderer; its texture stack is extended
with the paths this spritesheet extracts from data.
update_mode: How often get_image_index is re-run for a tile - see UpdateMode.
data = data
instance-attribute
#
path_map = renderer._add_textures(self._extract_paths(data))
instance-attribute
#
update_mode = update_mode
instance-attribute
#
get_image_index(tile, neighbors)
#
Standardized function to get the image_index for any given tile. The frequency this is run is determined by the tilemap's 'update_mode'.
:param tile: The tile that the image index is being gotten for. :type tile: Tile
:param neighbors: The 8 neighbors of the given tile, ordered in the clockwise direction stating in the top left. Includes neighbors in nearby chunks. :type neighbors: tuple[Tile, Tile, Tile, Tile, Tile, Tile, Tile, Tile]
:rtype: int
get_name()
staticmethod
#
The type name spritesheet data uses to select this class (see Tilemap.add_spritesheet_type).
update()
#
Called when the tilemap node is updated.
UpdateMode
#
Determines when the 'get_image_index' function will be called. Frame means every its called every frame. Chunk means its called on every chunk update. Once is only called once per tile. Never means it will never be called, and the image id will be used instead.