CLASS v1.8.0

tilemap.Map

pykraken.tilemap.Map

A TMX map with access to its layers and tilesets.

More about tilemap.Map

Attributes

  • background_color (Color) — Map background color.
  • orientation (MapOrientation) — Map orientation enum.
  • render_order (MapRenderOrder) — Tile render order enum.
  • map_size (Vec2) — Tile grid dimensions.
  • tile_size (Vec2) — Size of individual tiles.
  • bounds (Rect) — Map bounds in pixels.
  • hex_side_length (float) — Hex side length for hex maps.
  • stagger_axis (MapStaggerAxis) — Stagger axis enum for staggered/hex maps.
  • stagger_index (MapStaggerIndex) — Stagger index enum.
  • tile_sets (TileSetList) — List of TileSet objects.
  • all_layers (LayerList) — List of Layer instances.
  • tile_layers (List[TileLayer]) — List of tile layers.
  • object_groups (List[ObjectGroup]) — List of object groups.
  • image_layers (List[ImageLayer]) — List of image layers.

Methods

  • load — Load a TMX file from path.
  • draw — Draw all layers.
  • get_layer — Get a layer by name.

Reference

PYTHON API
tilemap.Map(tmx_path: str | PathLike = '')

Create a Map with the option to load an initial TMX file from the given path.

Args

  • tmx_path (str | PathLike[str], optional) — Path to the TMX file to load during construction.

all_layers

property
all_layers: tilemap.LayerList

LayerList of layers in the map.

background_color: Color

Map background color.

bounds

property
bounds: Rect

Map bounds in pixels.

hex_side_length: float

Hex side length for hex maps.

image_layers

property
image_layers: list[tilemap.ImageLayer]

List of image layers in the map.

map_size

property
map_size: Vec2

Map dimensions in tiles.

object_groups: list[tilemap.ObjectGroup]

List of object group layers in the map.

orientation

property
orientation: tilemap.MapOrientation

Map orientation enum.

render_order

property
render_order: tilemap.MapRenderOrder

Tile render order enum.

stagger_axis

property
stagger_axis: tilemap.MapStaggerAxis

Stagger axis enum for staggered/hex maps.

stagger_index: tilemap.MapStaggerIndex

Stagger index enum for staggered/hex maps.

tile_layers

property
tile_layers: list[tilemap.TileLayer]

List of tile layers in the map.

tile_sets

property
tile_sets: tilemap.TileSetList

TileSetList of tilesets used by the map.

tile_size

property
tile_size: Vec2

Size of tiles in pixels.

draw

method
draw(self, angle: float = 0.0, pivot: Vec2 = Vec2(0.500000, 0.500000)) -> None

Draw all layers.

Args

  • angle (float, optional) — Rotation angle in degrees to apply to the entire map. Defaults to 0.0.
  • pivot (Vec2, optional) — Pivot point for rotation, as normalized coordinates relative to the map size. Defaults to (0.5, 0.5).

get_layer

method
get_layer(self, name: str) -> tilemap.Layer

Get a layer by its name. Will return None if not found.

Args

  • name (str) — Name of the layer to retrieve.

load

method
load(self, tmx_path: str | PathLike) -> None

Load a TMX file from path.

Args

  • tmx_path (str | PathLike[str]) — Path to the TMX file to load.

Find your next step

Start typing to search the manual.