This repository aims to provide go support for maps that are saved according the the TMX Map Format
This library currently supports loading of base64 encoded tile maps with either gzip, zlip or no compression.
Currently the library only provides functionality to load maps, in the future it should provide utility functions to make using tmx files even more convenient.
To generate a preview image of your tilemap you can use the Render function:
testfile := "example.tmx"
reader, err := os.Open(testfile)
m, err := tmx.NewMap(reader)
if err != nil {
log.Fatal(err)
}
canvas := tmx.NewImageCanvasFromMap(*m)
renderer := tmx.NewRenderer(*m, canvas)
err = renderer.Render()
if err != nil {
log.Fatal(err)
}
target, err := os.Create("result.png")
if err != nil {
target, err = os.Open("result.png")
if err != nil {
log.Fatal(err)
}
}
defer target.Close()
err = png.Encode(target, canvas.Image())
if err != nil {
log.Fatal(err)
}
The renderer is still a work in progress and currently only renders tiles and layers.