Nim bindings for Tilengine - a free, cross-platform 2D graphics engine for creating classic/retro games with tile maps, sprites and palettes.
Refer to the C docs and peek at the Nim source to get a feel for things.
These Nim bindings are close to the C bindings, with the following changes:
Tileobjects have accessors (e.g.
t.flipx = true) so you don't have to get your hands dirty with bitwise operations.
ptr UncheckedArray[T]is used instead of
Note: these bindings do use manual memory management, so you must call
map.delete() etc. to avoid leaks.
import tilengine # Initialise the engine let engine = init(400, 240, numLayers = 1, numSprites = 0, numAnimations = 0) # Load a tilemap let map = loadTilemap("assets/forest/map.tmx") # Modify a tile let (x, y) = (10, 12) var tile = map.getTile(y, x) tile.flipx = true map.setTile(y, x, tile) # Assign tilemap to layer const layer = Layer(0) layer.setTilemap(map) # Create window and run game loop createWindow() while processWindow(): drawFrame() # Cleanup map.delete() deleteWindow() deinit()
You will need the following shared libraries installed on your system or placed in the same directory as your executable.
Clone the repo, use nimble to install it, then try building the example!
git clone https://git.sr.ht/~exelotl/nim-tilengine cd nim-tilengine nimble install cd examples nim c -r example.nim