tmxmap

package module
v0.0.0-...-d90e7e7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 8, 2019 License: MIT Imports: 16 Imported by: 7

README

tmxmap

A go module to read TMX tile maps from tiled map editor (https://www.mapeditor.org/)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NilTile = &TileInfo{Nil: true}

Functions

This section is empty.

Types

type Chunk

type Chunk struct {
	X         int        `xml:"x,attr"`
	Y         int        `xml:"y,attr"`
	Width     int        `xml:"width,attr"`
	Height    int        `xml:"height,attr"`
	DataTiles []DataTile `xml:"tile"`
}

type Data

type Data struct {
	Encoding    string     `xml:"encoding,attr"`
	Compression string     `xml:"compression,attr"`
	RawData     []byte     `xml:",innerxml"`
	DataTiles   []DataTile `xml:"tile"`
	Chunk       []Chunk    `xml:"chunk"`
}

type DataTile

type DataTile struct {
	GID GID `xml:"gid,attr"`
}

type GID

type GID uint32

type Image

type Image struct {
	Source string `xml:"source,attr"`
	Trans  string `xml:"trans,attr"`
	Width  int    `xml:"width,attr"`
	Height int    `xml:"height,attr"`
	Image  image.Image
}

type Layer

type Layer struct {
	ID         int        `xml:"id,attr"`
	Name       string     `xml:"name,attr"`
	X          int        `xml:"x,attr"`
	Y          int        `xml:"y,attr"`
	Width      int        `xml:"width,attr"`
	Height     int        `xml:"height,attr"`
	Opacity    float32    `xml:"opacity,attr"`
	Visible    bool       `xml:"visible,attr"`
	OffsetX    int        `xml:"offsetx,attr"`
	OffsetY    int        `xml:"offsety,attr"`
	Properties []Property `xml:"properties>property"`
	Data       Data       `xml:"data"`
	Tiles      []*TileInfo
}

type Map

type Map struct {
	Version         string        `xml:"version,attr"`
	TiledVersion    string        `xml:"tiledversion,attr"`
	Orientation     string        `xml:"orientation,attr"`
	RenderOrder     string        `xml:"renderorder,attr"`
	Width           int           `xml:"width,attr"`
	Height          int           `xml:"height,attr"`
	TileWidth       int           `xml:"tilewidth,attr"`
	TileHeight      int           `xml:"tileheight,attr"`
	HexSideLength   int           `xml:"hexsidelength,attr"`
	StaggerAxis     int           `xml:"staggeraxis,attr"`
	StaggerIndex    int           `xml:"staggerindex,attr"`
	BackgroundColor string        `xml:"backgroundcolor,attr"`
	NextLayerID     int           `xml:"nextlayerid,attr"`
	NextObjectID    int           `xml:"nextobjectid,attr"`
	Properties      []Property    `xml:"properties>property"`
	TileSets        []TileSet     `xml:"tileset"`
	Layers          []Layer       `xml:"layer"`
	ObjectGroups    []ObjectGroup `xml:"objectgroup"`
}

Map represents the TMX Map Format https://doc.mapeditor.org/en/stable/reference/tmx-map-format/

func Decode

func Decode(tileMap io.Reader) (*Map, error)

Load

func Load

func Load(name string) (*Map, error)

Load

type Object

type Object struct {
	Name       string     `xml:"name,attr"`
	Type       string     `xml:"type,attr"`
	X          int        `xml:"x,attr"`
	Y          int        `xml:"y,attr"`
	Width      int        `xml:"width,attr"`
	Height     int        `xml:"height,attr"`
	GID        int        `xml:"gid,attr"`
	Visible    bool       `xml:"visible,attr"`
	Properties []Property `xml:"properties>property"`
	Polygons   []Polygon  `xml:"polygon"`
	PolyLines  []PolyLine `xml:"polyline"`
}

type ObjectGroup

type ObjectGroup struct {
	Name       string     `xml:"name,attr"`
	Color      string     `xml:"color,attr"`
	Opacity    float32    `xml:"opacity,attr"`
	Visible    bool       `xml:"visible,attr"`
	Properties []Property `xml:"properties>property"`
	Objects    []Object   `xml:"object"`
}

type PolyLine

type PolyLine struct {
	Points string `xml:"points,attr"`
}

type Polygon

type Polygon struct {
	Points string `xml:"points,attr"`
}

type Property

type Property struct {
	Name  string `xml:"name,attr"`
	Value string `xml:"value,attr"`
}

type Tile

type Tile struct {
	ID    GID   `xml:"id,attr"`
	Image Image `xml:"image"`
}

type TileInfo

type TileInfo struct {
	ID             GID
	TileSet        *TileSet
	HorizontalFlip bool
	VerticalFlip   bool
	DiagonalFlip   bool
	Nil            bool
}

type TileSet

type TileSet struct {
	FirstGID   GID        `xml:"firstgid,attr"`
	Source     string     `xml:"source,attr"`
	Name       string     `xml:"name,attr"`
	TileWidth  int        `xml:"tilewidth,attr"`
	TileHeight int        `xml:"tileheight,attr"`
	Spacing    int        `xml:"spacing,attr"`
	Margin     int        `xml:"margin,attr"`
	Properties []Property `xml:"properties>property"`
	Image      *Image     `xml:"image"`
	Tiles      []Tile     `xml:"tile"`
	Tilecount  int        `xml:"tilecount,attr"`
	Columns    int        `xml:"columns,attr"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL