World > Tiled Elements#
TiledWorld exposes tile helper classes for grid-based projects. They are most
useful when you need to inspect or customize tiles, edges, or corners directly.
TileFactory#
- class miniworlds.worlds.tiled_world.tile_factory.TileFactory[Quellcode]#
TileBase#
- class miniworlds.worlds.tiled_world.tile_elements.TileBase(position, world=None)[Quellcode]#
Base class for Tiles and TileDelimiters (like Corners, Edges).
- add_actor(actor)[Quellcode]#
Places an actor on this tile.
- classmethod from_pixel(pixel_position, world)[Quellcode]#
Finds the nearest tile to a given pixel coordinate.
This method uses caching to avoid redundant recalculation of the mapping between tile grid positions and their corresponding pixel coordinates for a given world. It also uses squared distance instead of Euclidean distance for better performance.
- abstract classmethod from_position(position, world)[Quellcode]#
Create a tile from a world-relative position.
- Rückgabetyp:
- get_actors()[Quellcode]#
Returns all actors currently on this tile.
- Rückgabetyp:
- static get_local_center_coordinate(world)[Quellcode]#
Returns the center point offset for a tile, in local pixel coordinates.
- get_local_corner_points()[Quellcode]#
Returns corner point offsets for rendering.
- get_neighbour_tiles()[Quellcode]#
Returns neighboring tiles around this tile.
- static get_position_pixel_dict(world)[Quellcode]#
Returns a mapping of tile positions to pixel coordinates.
- Rückgabetyp:
- merge(other)[Quellcode]#
Merge tile positions from another tile at the same location.
Tile#
- class miniworlds.worlds.tiled_world.tile.Tile(position, world=None)[Quellcode]#
- corner_vectors: OrderedDict[str, Tuple[float, float]] = {'no': (-0.5, 0.5), 'nw': (0.5, 0.5), 'so': (-0.5, -0.5), 'sw': (0.5, -0.5)}#
- distance_to(other)[Quellcode]#
- Rückgabetyp:
- edge_vectors: dict[str, Tuple[float, float]] = {'n': (0, -0.5), 'o': (0.5, 0), 's': (0, 0.5), 'w': (-0.5, 0)}#
- classmethod from_actor(actor)[Quellcode]#
- Rückgabetyp:
- classmethod from_pixel(pixel_position, world=None)[Quellcode]#
Finds the nearest tile to a given pixel coordinate.
This method uses caching to avoid redundant recalculation of the mapping between tile grid positions and their corresponding pixel coordinates for a given world. It also uses squared distance instead of Euclidean distance for better performance.
- classmethod from_position(position, world)[Quellcode]#
Create a tile from a world-relative position.
- Rückgabetyp:
- get_neighbour_corners()[Quellcode]#
- static get_position_pixel_dict(world)[Quellcode]#
Returns a mapping of tile positions to pixel coordinates.
- Rückgabetyp:
- tile_vectors: dict[str, Tuple[int, int]] = {'no': (-1, 1), 'nw': (1, 1), 'o': (-1, 0), 'so': (-1, -1), 'sw': (1, -1), 'w': (1, 0)}#
- to_center()[Quellcode]#
- to_pixel()[Quellcode]#
Edge#
- class miniworlds.worlds.tiled_world.edge.Edge(position, direction, world)[Quellcode]#
- angles: Dict[str, int] = {'n': 3, 'o': 0, 's': 1, 'w': 2}#
- direction_angles: Dict[str, int] = {'n': 90, 'o': 0, 's': 90, 'w': 0}#
- static direction_vectors()[Quellcode]#
Returns the available directions.
- classmethod from_position(position, world)[Quellcode]#
Create a tile delimiter (override expected).
- static get_position_pixel_dict(world)[Quellcode]#
Returns a mapping of tile positions to pixel coordinates.
- start_angle()[Quellcode]#
Override: starting angle offset for layouting (e.g. hex rotation).
- tile_vectors: dict = {'n': [(0, 0.5), (0, -0.5)], 'o': [(-0.5, 0), (0.5, 0)], 's': [(0, 0.5), (0, -0.5)], 'w': [(-0.5, 0), (0.5, 0)]}#
Corner#
- class miniworlds.worlds.tiled_world.corner.Corner(position, direction, world)[Quellcode]#
- angles: Dict[str, int] = {'no': 0, 'nw': 1, 'so': 3, 'sw': 2}#
- direction_angles: Dict[str, int] = {'no': 0, 'nw': 0, 'so': 0, 'sw': 0}#
- static direction_vectors()[Quellcode]#
Returns the available directions.
- classmethod from_pixel(position, world=None)[Quellcode]#
Finds the nearest tile to a given pixel coordinate.
This method uses caching to avoid redundant recalculation of the mapping between tile grid positions and their corresponding pixel coordinates for a given world. It also uses squared distance instead of Euclidean distance for better performance.
- classmethod from_position(position, world)[Quellcode]#
Create a tile delimiter (override expected).
- classmethod from_tile(position, direction_string)[Quellcode]#
- start_angle()[Quellcode]#
Override: starting angle offset for layouting (e.g. hex rotation).