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.
At a glance
18 membersConstructormethodall_layerspropertybackground_colorpropertyboundspropertyhex_side_lengthpropertyimage_layerspropertymap_sizepropertyobject_groupspropertyorientationpropertyrender_orderpropertystagger_axispropertystagger_indexpropertytile_layerspropertytile_setspropertytile_sizepropertydrawmethodget_layermethodloadmethodReference
PYTHON APIConstructor
methodtilemap.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
propertyall_layers: tilemap.LayerListLayerList of layers in the map.
background_color
propertybackground_color: ColorMap background color.
bounds
propertybounds: RectMap bounds in pixels.
hex_side_length
propertyhex_side_length: floatHex side length for hex maps.
image_layers
propertyimage_layers: list[tilemap.ImageLayer]List of image layers in the map.
map_size
propertymap_size: Vec2Map dimensions in tiles.
object_groups
propertyobject_groups: list[tilemap.ObjectGroup]List of object group layers in the map.
orientation
propertyorientation: tilemap.MapOrientationMap orientation enum.
render_order
propertyrender_order: tilemap.MapRenderOrderTile render order enum.
stagger_axis
propertystagger_axis: tilemap.MapStaggerAxisStagger axis enum for staggered/hex maps.
stagger_index
propertystagger_index: tilemap.MapStaggerIndexStagger index enum for staggered/hex maps.
tile_layers
propertytile_layers: list[tilemap.TileLayer]List of tile layers in the map.
tile_sets
propertytile_sets: tilemap.TileSetListTileSetList of tilesets used by the map.
tile_size
propertytile_size: Vec2Size of tiles in pixels.
draw
methodDraw 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
methodget_layer(self, name: str) -> tilemap.LayerGet a layer by its name. Will return None if not found.
Args
- name (
str) — Name of the layer to retrieve.
load
methodload(self, tmx_path: str | PathLike) -> NoneLoad a TMX file from path.
Args
- tmx_path (
str | PathLike[str]) — Path to the TMX file to load.