ldtkbridgego

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: May 22, 2023 License: MIT Imports: 4 Imported by: 0

README

fluffy_anchovies

Another bridge between Golang / Ebiten and LDtk

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Definitions

type Definitions struct {
	Tilesets []TilesetDefinition `json:"tilesets"`
}

type EntityInstance

type EntityInstance struct {
	Identifier     string          `json:"__identifier"`
	Grid           []int           `json:"__grid"`
	Tile           TileRectangle   `json:"__tile"`
	FieldInstances []FieldInstance `json:"fieldInstances"`
}

type FieldInstance

type FieldInstance struct {
	Identifier string        `json:"__identifier"`
	Tile       TileRectangle `json:"__tile"`
	Type       string        `json:"__type"`
	Value      interface{}   `json:"__value"`
}

type LayerInstance

type LayerInstance struct {
	Type            string           `json:"__type"`
	Identifier      string           `json:"__identifier"`
	CHei            int              `json:"__cHei"`
	CWid            int              `json:"__cWid"`
	EntityInstances []EntityInstance `json:"entityInstances"`
	GridTiles       []TileInstance   `json:"gridTiles"`
	TilesetDefUid   int              `json:"__tilesetDefUid"`
	GridSize        int              `json:"__gridSize"`
	IntGridCsv      []int            `json:"intGridCsv"`
}

func (*LayerInstance) GetInt

func (layer *LayerInstance) GetInt(x, y int) int

type LdtkJSON

type LdtkJSON struct {
	Levels []Level     `json:"levels"`
	Defs   Definitions `json:"defs"`
}

func UnmarshalLdtkJSON

func UnmarshalLdtkJSON(data []byte) (LdtkJSON, error)

func (*LdtkJSON) GetLevelByName

func (world *LdtkJSON) GetLevelByName(name string) *Level

Return all json data of a LDtk Level with a given name

func (*LdtkJSON) GetLevelIndex

func (world *LdtkJSON) GetLevelIndex(name string) int

func (*LdtkJSON) Marshal

func (r *LdtkJSON) Marshal() ([]byte, error)

type Level

type Level struct {
	Identifier     string          `json:"identifier"`
	PxWid          int             `json:"pxWid"`
	PxHei          int             `json:"PxHei"`
	LayerInstances []LayerInstance `json:"layerInstances"`
	FieldInstances []FieldInstance `json:"fieldInstances"`
}

func (*Level) GetLayerByName

func (level *Level) GetLayerByName(name string) *LayerInstance

func (*Level) RenderLayerByName

func (level *Level) RenderLayerByName(screen *ebiten.Image, tilesetLib map[int]*ebiten.Image, name string, offsetX, offsetY, scale float64)

Render a layer with a given name

type TileInstance

type TileInstance struct {
	F   int   `json:"f"`
	T   int   `json:"t"`
	Src []int `json:"src"`
	Px  []int `json:"px"`
}

type TileRectangle

type TileRectangle struct {
	H          int `json:"h"`
	W          int `json:"w"`
	X          int `json:"x"`
	Y          int `json:"y"`
	TilesetUid int `json:"tilesetUid"`
}

type TilesetDefinition

type TilesetDefinition struct {
	Identifier string `json:"__identifier"`
	Uid        int    `json:"uid"`
	RelPath    string `json:"relPath"`
}

Jump to

Keyboard shortcuts

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