pixeltmx

package
v0.0.0-...-a02e23d Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2018 License: MIT Imports: 15 Imported by: 0

README

pixeltmx GoDoc

features

  • (Multiple) Tileset Support
    • Tileset Offset Support
  • Tile Layer Rendering
    • Visbility Support
    • Opacity Support
    • Offset Support
    • Draw-order Support
  • Object Layer Rendering
    • Color Support
    • Tile Rendering
    • Ellipse Rendering
    • Point Rendering
    • Polygon Rendering
    • Polyline Rendering
    • Text Rendering
  • Image Layer Rendering
  • Layer Group Rendering

non-features (at least for now)

  • isometric maps
  • hex maps

Documentation

Index

Constants

View Source
const (
	TileLayerDrawer = iota
	ObjectGroupDrawer
	ImageLayerDrawer
	GroupDrawer
)

Drawer Types

Variables

This section is empty.

Functions

This section is empty.

Types

type Drawer

type Drawer interface {
	Type() int
	Info() *LayerInfo
	Update() error
	Draw(target pixel.Target)
}

Drawer is the base interface for the pixeltmx library, there are 4 concrete implementations for the 4 types of tmx layers (tile layer, object group, image layer, group layer). The underlying type can be extracted using `Type()` method. Each Layer will be updated once on creation and remain cached for subsequent draws. If the underlying data or resources have been changed, the `Update()` method must be called before the changes will be visible when drawing.

func NewDrawer

func NewDrawer(resources *Resources, parent Drawer, layer *tmx.Layer) (Drawer, error)

NewDrawer creates a Drawer which will render the layer and recursively draw all child layers.

func NewRootDrawer

func NewRootDrawer(resources *Resources, mapData *tmx.Map) (Drawer, error)

NewRootDrawer will create a special Drawer that will recursively draw the entire tmx map.

type LayerInfo

type LayerInfo struct {
	// contains filtered or unexported fields
}

LayerInfo provides drawing information for the layer, it holds the recursively calculated offset, visibility, and color information, as well as a reference to the base map data. It prevides easy methods translating between tmx and pixel world coordinates.

func (*LayerInfo) TMXToPixelRect

func (li *LayerInfo) TMXToPixelRect(x, y, w, h float64) pixel.Rect

TMXToPixelRect translates a TMX four-tuple (x, y, w, h) to a pixel.Rect in pixel world coordinates.

func (*LayerInfo) TMXToPixelVec

func (li *LayerInfo) TMXToPixelVec(x, y float64) pixel.Vec

TMXToPixelVec translates TMX x and y coordinates to a pixel.Vect in pixel world coordinates.

func (*LayerInfo) TileRect

func (li *LayerInfo) TileRect(cell int) (pixel.Rect, error)

TileRect returns the pixel.Rect of a TMX map tile in pixel world coordinates.

type Resources

type Resources struct {
	// contains filtered or unexported fields
}

Resources holds all the raw images and miscellaneous files required for rendering a TMX map. This includes tilesets and tileset pictures, raw images, object templates, etc.

func LoadResources

func LoadResources(mapData *tmx.Map, path string) (*Resources, error)

LoadResources searches through the tmx map tree and loads any resources found. If the resources are located somewhere other than the current working directory, the location should be supplied in the path string.

Notes

Bugs

  • something strange is happening with polygon rendering.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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