simvx.core.tilemap

TileMap and TileSet for grid-based 2D level design.

Module Contents

Classes

TileData

Per-tile metadata within a TileSet.

TileSet

Collection of tiles from one or more texture atlases.

TileMapLayer

A single layer within a TileMap. Stores tiles in chunks for large maps.

TileMap

Grid-based 2D map with multiple layers. Uses chunk-based storage.

Data

API

simvx.core.tilemap.__all__

[‘TileData’, ‘TileSet’, ‘TileMapLayer’, ‘TileMap’]

class simvx.core.tilemap.TileData

Per-tile metadata within a TileSet.

texture_region: tuple[int, int, int, int]

(0, 0, 0, 0)

collision_shapes: list

‘field(…)’

navigation_polygon: list | None

None

custom_data: dict

‘field(…)’

animation_frames: list[int] | None

None

animation_speed: float

5.0

terrain_type: str = <Multiline-String>
terrain_set: int

0

terrain_bits: int

0

class simvx.core.tilemap.TileSet(tile_size: tuple[int, int] = (16, 16))

Collection of tiles from one or more texture atlases.

Initialization

add_tile(tile_data: simvx.core.tilemap.TileData | None = None) int

Add a tile, return its ID.

get_tile(tile_id: int) simvx.core.tilemap.TileData | None
remove_tile(tile_id: int)
property tile_count: int
create_from_grid(atlas_width: int, atlas_height: int) list[int]

Auto-create tiles from a grid atlas. Returns list of tile IDs.

add_terrain_set(set_id: int = 0)

Create a terrain set for auto-tiling.

set_terrain_tile(set_id: int, bitmask: int, tile_id: int)

Map a neighbor bitmask to a tile ID for auto-tiling.

get_terrain_tile(set_id: int, bitmask: int) int | None

Look up tile ID for a given neighbor bitmask.

simvx.core.tilemap.CHUNK_SIZE

32

class simvx.core.tilemap.TileMapLayer(name: str = 'Layer 0')

A single layer within a TileMap. Stores tiles in chunks for large maps.

Initialization

set_cell(x: int, y: int, tile_id: int)

Set a tile at grid position (x, y).

get_cell(x: int, y: int) int

Get tile ID at grid position. Returns -1 if empty.

erase_cell(x: int, y: int)
get_used_cells() list[tuple[int, int]]

Return all non-empty cell positions.

get_used_rect() tuple[int, int, int, int]

Return bounding rect (x, y, w, h) of used cells.

class simvx.core.tilemap.TileMap(name='TileMap', **kwargs)

Bases: simvx.core.engine.Node2D

Grid-based 2D map with multiple layers. Uses chunk-based storage.

Initialization

tile_set

‘Property(…)’

cell_size

‘Property(…)’

add_layer(name: str = '') int

Add a new layer. Returns its index.

get_layer(index: int) simvx.core.tilemap.TileMapLayer
property layer_count: int
set_cell(layer: int, x: int, y: int, tile_id: int)
get_cell(layer: int, x: int, y: int) int
erase_cell(layer: int, x: int, y: int)
world_to_map(world_pos: tuple[float, float]) tuple[int, int]

Convert world position to grid coordinates.

map_to_world(map_pos: tuple[int, int]) tuple[float, float]

Convert grid coordinates to world position (center of cell).

get_neighbor_bitmask(layer: int, x: int, y: int) int

Calculate 4-bit bitmask for auto-tiling.

Bits: up=1, right=2, down=4, left=8. A neighbor bit is set when the adjacent tile shares the same terrain_type as the center tile.

auto_tile(layer: int, x: int, y: int, terrain_set: int = 0)

Update tile at (x, y) based on neighbors using auto-tile rules.

z_index

‘Property(…)’

z_as_relative

‘Property(…)’

property absolute_z_index: int
property position: simvx.core.math.types.Vec2
property rotation: float
property rotation_degrees: float
property scale: simvx.core.math.types.Vec2
property global_position: simvx.core.math.types.Vec2
property global_rotation: float
property global_scale: simvx.core.math.types.Vec2
property forward: simvx.core.math.types.Vec2
property right: simvx.core.math.types.Vec2
translate(offset: tuple[float, float] | numpy.ndarray)
rotate(radians: float)
rotate_deg(degrees: float)
look_at(target: tuple[float, float] | numpy.ndarray)
transform_points(points: list[simvx.core.math.types.Vec2]) list[simvx.core.math.types.Vec2]
draw_polygon(renderer, points: list[simvx.core.math.types.Vec2], closed=True, color=None)
wrap_screen(margin: float = 20)
script_error_raised

‘Signal(…)’

classmethod __init_subclass__(**kwargs)
property name: str
property process_mode: simvx.core.descriptors.ProcessMode
reset_error() None
add_child(node: simvx.core.node.Node) simvx.core.node.Node
remove_child(node: simvx.core.node.Node)
reparent(new_parent: simvx.core.node.Node)
get_node(path: str) simvx.core.node.Node
find_child(name: str, recursive: bool = False) simvx.core.node.Node | None
find(node_type: type) simvx.core.node.Node | None
find_all(node_type: type, recursive: bool = True) list
property path: str
add_to_group(group: str)
remove_from_group(group: str)
is_in_group(group: str) bool
ready() None
enter_tree() None
exit_tree() None
process(dt: float) None
physics_process(dt: float) None
draw(renderer) None
input_event(event: simvx.core.events.InputEvent) None
input(event: simvx.core.events.TreeInputEvent) None
unhandled_input(event: simvx.core.events.TreeInputEvent) None
start_coroutine(gen: simvx.core.descriptors.Coroutine) simvx.core.descriptors.CoroutineHandle
stop_coroutine(gen_or_handle)
destroy()
queue_free

None

property tree: simvx.core.scene_tree.SceneTree
get_tree() simvx.core.scene_tree.SceneTree
__getitem__(key: str)
classmethod get_properties() dict[str, simvx.core.descriptors.Property]
get_settings

None

__repr__()