tstructs
Tile map data structures for 2D and 3D worlds.
Table of Contents
Overview
tstructs is a Python package providing foundational data structures for representing and manipulating tile maps in both 2D and 3D environments. It is designed for use in games, simulations, and applications that require efficient spatial organization of map data.
Features
- Coordinate: Immutable tuple subclass for 2D/3D coordinates with convenient accessors.
- Region: Represents a square 3D region in a tile map, with properties for area, volume, and bounds checking.
- ChunkedRegion: Extends
Regionto support chunking, allowing subdivision of regions into smaller, manageable chunks.
Module Information
- Name: tstructs
- Version: 1.2.0
- Description: Tile map data structures for 2D and 3D worlds.
Installation
This package is intended for use as part of a larger project. To use it directly or install it as a package.
# Example pip install
pip install tstructs
# Example: Add to PYTHONPATH
export PYTHONPATH="$PYTHONPATH:/path/to/install/tstructs"
Usage
Import the classes you need:
from tstructs import Coordinate, Region, ChunkedRegion, Cell, Group, Properties
# 2D coordinate
c2 = Coordinate(1, 2)
# 3D coordinate
c3 = Coordinate(1, 2, 3)
# Create a region
region = Region(region_size=16, region_location=Coordinate(0, 0))
# Create a chunked region
chunked = ChunkedRegion(region_size=16, chunk_size=4, region_location=Coordinate(0, 0))
# Create a cell
cell = Cell(coord=Coordinate(1, 2), value=5)
# Create a group of cells
group = Group([cell])
# Create and use properties
props = Properties({'walkable': True, 'cost': 1})
is_walkable = props['walkable']
API Reference
Coordinate
- 2D or 3D immutable coordinate:
Coordinate(x, y)orCoordinate(x, y, z) - Properties:
.x,.y,.z(z only for 3D)
Region
Region(region_size, region_location=Coordinate(0,0))- Properties:
.name,.n(size),.area,.volume,.centre - Methods:
.clamp_coordinates(start_x, start_y, end_x, end_y),.is_edge(x, y)
ChunkedRegion
ChunkedRegion(region_size, chunk_size, region_location=Coordinate(0,0))- Properties:
.chunks_per_side,.total_chunks - Methods:
.get_chunk_coordinates(loc),.get_chunks_in_area(start, end)
Cell
Cell(coord, value=None, **attributes)- Represents a single tile or cell in a map, with a coordinate and optional value/attributes.
- Properties:
.coord,.value,.attributes(dict of extra attributes) - Example:
Cell(Coordinate(1,2), value=5, terrain='grass')
Group
Group(cells=None)- Represents a collection of
Cellobjects. - Methods:
.add(cell): Add a cell to the group.remove(cell): Remove a cell from the group.find_by_coord(coord): Find a cell by its coordinate
- Iterable: Can be iterated over like a list of cells
Properties
Properties(data=None)- Dictionary-like class for storing arbitrary properties for tiles, cells, or regions.
- Behaves like a dict: supports item access, update, iteration, etc.
- Example:
Properties({'walkable': True, 'cost': 1})
Testing
See docs/testing.md for information on testing and usage examples.
License
This package is licensed under the GNU General Public License v3.0 (GPLv3). See the LICENSE file for details.
Metadata
Release files for tstructs 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| tstructs-1.2.0.tar.gz | 22.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tstructs-1.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 45.0 kB
Release files / tstructs-1.2.0.tar.gz
| Download URL | tstructs-1.2.0.tar.gz |
|---|---|
| Size | 22.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2c836c55672c0970a047ab2ef73a75603c1765d9e49ac3dfb759e2f81ff4a082
|
|
BLAKE2b-256 checksum How to use checksums |
ca2304218d5ac37cd7955c4efd35a3405d3fd67d1a0e25dad3023cca2997c38b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.10.8
|
Release files / tstructs-1.2.0-py3-none-any.whl
| Download URL | tstructs-1.2.0-py3-none-any.whl |
|---|---|
| Size | 22.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
29b8a78fa87835054f92154d0ef4f1597d992fd958accfd74954b232e27eb8c2
|
|
BLAKE2b-256 checksum How to use checksums |
5e23a8c6b81d340e5ab232903a6286198a32e4cd3b379d09f0f552a2e0266bf4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.10.8
|
Security for tstructs 1.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.