This package provides foundational data structures for representing and manipulating tile maps in 2D and 3D environments. Its primary purpose is to enable efficient spatial organization and management of map data for games, simulations, and applications that require robust handling of coordinates, regions, and chunked regions. By offering specialized classes for coordinates, regions, and chunked regions, the package simplifies the development of systems that need precise and scalable map logic.
Project description
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.0.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, add the foundation_packages/tstructs/tstructs directory to your Python path or install it as a local package.
# Example: Add to PYTHONPATH
export PYTHONPATH="$PYTHONPATH:/path/to/foundation_packages/tstructs"
Usage
Import the classes you need:
from tstructs import Coordinate, Region, ChunkedRegion
# 2D coordinate
c2 = Coordinate(1, 2)
# 3D coordinate
c3 = Coordinate(1, 2, 3)
# Create a region
region = Region(region_x=0, region_y=0, region_size=16, region_location=Coordinate(0, 0))
# Create a chunked region
chunked = ChunkedRegion(region_x=0, region_y=0, region_size=16, chunk_size=4, region_location=Coordinate(0, 0))
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_x, region_y, 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_x, region_y, 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)
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.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tstructs-1.0.0.tar.gz.
File metadata
- Download URL: tstructs-1.0.0.tar.gz
- Upload date:
- Size: 18.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b331131e7e1ab9b6310e34024bc7b9822667987810ae60360a4a650b8f67cc66
|
|
| MD5 |
c285cb531878175a722da016b7797dfa
|
|
| BLAKE2b-256 |
24afd6107e6b29bbcc50ee88fafb1f25c9cb56fb1aa0ce9a6309032c259c5ce4
|
File details
Details for the file tstructs-1.0.0-py3-none-any.whl.
File metadata
- Download URL: tstructs-1.0.0-py3-none-any.whl
- Upload date:
- Size: 19.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d95bfef14c0d63f76e5797446c59b297f42e62ab107b35a34a364fb2a7ef83f
|
|
| MD5 |
f530d1d21497c8c7a590fddfb9b4947f
|
|
| BLAKE2b-256 |
bb29d07a92444b0df49d64cdf2924033245e723e02afe16eaf3160df885979ca
|