https://github.com/msg555/dustmaker
A library for reading and manipulating Dustforce level files
https://github.com/msg555/dustmaker
Last synced: 26 days ago
JSON representation
A library for reading and manipulating Dustforce level files
- Host: GitHub
- URL: https://github.com/msg555/dustmaker
- Owner: msg555
- License: apache-2.0
- Created: 2015-09-27T20:40:05.000Z (over 10 years ago)
- Default Branch: main
- Last Pushed: 2024-05-19T20:46:57.000Z (almost 2 years ago)
- Last Synced: 2025-12-29T07:36:32.709Z (2 months ago)
- Language: Python
- Size: 934 KB
- Stars: 7
- Watchers: 5
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
Dustmaker
=========
Dustmaker is a Python library for reading, manipulation, and writing
binary files used by Dustforce, primarily level files.
Documentation
-------------
Documentation can be found at
[https://dustmaker.readthedocs.io/en/latest/](https://dustmaker.readthedocs.io/en/latest/).
Installation
------------
Install with pip through PyPi using
python -m pip install dustmaker
or clone this repository and install using
./setup.py install
Command Line Tool
---------------------------
Dustmaker comes with a few command line tools that can be accessed through
running the dustmaker module.
```bash
$ python -m dustmaker --help
... listing of available utilities
$ python -m dustmaker transform --upscale 2 downhill big_downhill
... creates upscaled version of downhill and saves to "big_downhill"
```
Example: Creating a new level from scratch
---------------------------
```python
from dustmaker.level import Level
from dustmaker.tile import Tile, TileShape
from dustmaker.dfwriter import DFWriter
# Create a new empty level and add some tiles.
level = Level()
level.name = b"my level!"
level.virtual_character = True
for i, shape in enumerate(TileShape):
level.tiles[(19, 2 * i, i)] = Tile(shape)
# Automatically figure out edge solidity and connectivity flags
level.calculate_edge_visibility()
level.calculate_edge_caps()
# Write level to a file
with DFWriter(open("mylevel.dflevel", "wb")) as writer:
writer.write_level(level)
```
Example: Counting how many apples are in a level
--------------------------
```python
from dustmaker.dfreader import DFReader
from dustmaker.entity import Apple
with DFReader(open("mylevel.dflevel", "rb")) as reader:
level = reader.read_level()
apples = 0
for x, y, entity in level.entities.values():
if isinstance(entity, Apple):
apples += 1
print(f"Level has {apples} apples")
```