PyTilengine is the Python binding for Tilengine. It is not a direct 1:1 API translation of the original C library, but it uses familiar Python constructions as classes, lists, etc, and has its own documentation.
- /src directory contains the single
tilengine.py
module with the binding itself - /samples directory contains various examples ready to run and test
- /doc directory contains the source files for the sphinx documentation tool
Tilengine native shared library must be installed separately. Please refer to https://github.com/megamarc/Tilengine about how to do it.
No install step is required. Just make sure that the Tilengine library and the tilengine.py
modules are accessible from within your own project
Online version of the generated docs can be found in the following address: http://www.tilengine.org/doc_python/
The following program does these actions:
- Import required classes from tilengine binding
- Initialize the engine with a resolution of 400x240, one layer, no sprites and 20 animation slots
- Set the loading path to the assets folder
- Load a tilemap, the asset that contains background layer data
- Attach the loaded tilemap to the allocated background layer
- Create a display window with default parameters: windowed, auto scale and CRT effect enabled
- Run the window loop, updating the display at each iteration until the window is closed
Source code:
from tilengine import Engine, Window, Tilemap
engine = Engine.create(400, 240, 1, 0, 20)
engine.set_load_path("assets/sonic")
foreground = Tilemap.fromfile("sonic_md_fg1.tmx")
engine.layers[0].setup(foreground)
window = Window.create()
while window.process():
window.draw_frame()
Resulting output:
To run the samples, just open a terminal window inside the "samples" directory and run any of these commands:
python column_offset.py
python dkc.py
python mode7.py
python mosaic.py
python pixel_map.py
python platformer.py
python test.py
python vertical.py
PyTilengine is released under the permissive MIT license