Skip to content

Latest commit

 

History

History
57 lines (41 loc) · 1.79 KB

Readme.md

File metadata and controls

57 lines (41 loc) · 1.79 KB

Join the chat at https://gitter.im/manyminds/tmx

GoDoc Build Status Coverage Status Go Report Card

TMX Map File Loader

This repository aims to provide go support for maps that are saved according the the TMX Map Format

Support

This library currently supports loading of base64 encoded tile maps with either gzip, zlip or no compression.

Usage

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.

Renderer

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.