Skip to content

talvor/tsx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tsx

A go module to read TSX tilesets from tiled map editor (https://www.mapeditor.org/)

Reading individual tilesets

To read in a tileset use the tsx.LoadFile function

package main

import (
    "encoding/json"
    "fmt"

    "github.com/talvor/tsx"
)

func main() {
  tileset, err := tsx.LoadFile("~/Documents/tilesets/player.tsx")
  if err != nil {
    panic(err)
  }

  tsJSON, _ := json.Marshal(tileset)
  fmt.Println(string(tsJSON))
}

Managing multiple tilesets using TilesetManager

To read in bulk tilesets use the TilesetManager struct.

package main

import "github.com/talvor/tsx"

func main() {
	// Create a new tileset manager and load all tilesets from the directory
	tsm := tsx.NewTilesetManager("/home/phillip/Documents/tilesets")
	tsm.AddTileset("/home/phillip/Documents/tilesets/player.tsx")

	tileset, _ := tsm.GetTilesetBySource("/home/phillip/Documents/tilesets/player.tsx")
	tileset, _ = tsm.GetTilesetByName("player")
}

Using the renderer

The tsx.renderer works with the TilesetManager and the ebitenengine 2D game engine to provide convenient methods for rendering tilesets into the ebiten screen.

See renderer/examples/main.go for an example of using the renderer

About

A go module to read TSX tilesets from tiled map editor (https://www.mapeditor.org/)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages