tile

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CollisionFuncs [tcsts.GeometryMaxSentinel]func(ctx *context.Context, tileOrient Orientation, tileRect, targetRect image.Rectangle) bool
View Source
var LandingFuncs [tcsts.GeometryMaxSentinel]func(ctx *context.Context, tileOrient Orientation, tileRect image.Rectangle, ox, fx, y int) bool

Functions

func DrawAt

func DrawAt(canvas *ebiten.Image, ctx *context.Context, carrots *carrot.Inventory, x, y int, id uint8, variation uint8, orientation Orientation)

Types

type Map

type Map struct {
	Layers [][]Tile // for indexing, see tcsts.Layer* constants

	ID          uint8    // can't be zero
	TransferIDs [3]uint8 // 0 means undefined, not allowed as a map ID
	StartRow    uint8
	StartCol    uint8
}

Raw map structure. For actual play, we reorganize data a bit, as most content can be predrawn, and collisions can be prepared into a few 32x18 arrays.

func LoadMapFromString

func LoadMapFromString(data string) (*Map, error)

func NewMap

func NewMap(id uint8) *Map

func (*Map) Collides

func (self *Map) Collides(ctx *context.Context, carrots *carrot.Inventory, rect image.Rectangle, layer int) bool

Called like tilemap.Collides(ctx, rect, tcsts.LayerBack/LayerMain/LayerFront)

func (*Map) DeleteTile

func (self *Map) DeleteTile(row, col int, layerIndex int)

func (*Map) DrawBackLogical

func (self *Map) DrawBackLogical(canvas *ebiten.Image, ctx *context.Context, carrots *carrot.Inventory)

func (*Map) DrawFrontLogical

func (self *Map) DrawFrontLogical(canvas *ebiten.Image, ctx *context.Context, carrots *carrot.Inventory)

func (*Map) DrawMainLogical

func (self *Map) DrawMainLogical(canvas *ebiten.Image, ctx *context.Context, carrots *carrot.Inventory)

func (*Map) ExportToString

func (self *Map) ExportToString() (string, error)

func (*Map) GetFirstCollision

func (self *Map) GetFirstCollision(ctx *context.Context, carrots *carrot.Inventory, rect image.Rectangle, layer int) (Tile, bool)

func (*Map) GetTileIDAt

func (self *Map) GetTileIDAt(row, col uint8, layer int) (uint8, bool)

func (*Map) HasLandingFor

func (self *Map) HasLandingFor(ctx *context.Context, carrots *carrot.Inventory, ox, fx, y int, layer int) bool

func (*Map) LoadFromString

func (self *Map) LoadFromString(data string) error

func (*Map) SetTile

func (self *Map) SetTile(newTile Tile, layerIndex int)

type Orientation

type Orientation uint8

func (Orientation) ApplyToTileRect

func (self Orientation) ApplyToTileRect(rect image.Rectangle) image.Rectangle

func (Orientation) HasRotation

func (self Orientation) HasRotation() bool

func (Orientation) IsMirrored

func (self Orientation) IsMirrored() bool

func (Orientation) Mirrored

func (self Orientation) Mirrored() Orientation

func (Orientation) RotatedLeft

func (self Orientation) RotatedLeft() Orientation

func (Orientation) RotatedRight

func (self Orientation) RotatedRight() Orientation

func (Orientation) RotationDegs

func (self Orientation) RotationDegs() int

func (Orientation) RotationStr

func (self Orientation) RotationStr() string

type Tile

type Tile struct {
	ID          uint8
	Variation   uint8
	Orientation Orientation // only uses lowest 3 bits
	Row         uint8
	Column      uint8
}

func DecodeTileFromBytes

func DecodeTileFromBytes(bytes []byte) Tile

func (*Tile) Cmp

func (self *Tile) Cmp(other Tile) int

func (*Tile) Collides

func (self *Tile) Collides(ctx *context.Context, carrots *carrot.Inventory, rect image.Rectangle) bool

func (*Tile) Draw

func (self *Tile) Draw(canvas *ebiten.Image, ctx *context.Context, carrots *carrot.Inventory)

func (*Tile) DrawAt

func (self *Tile) DrawAt(canvas *ebiten.Image, ctx *context.Context, carrots *carrot.Inventory, x, y int)

func (*Tile) EncodeToBytes

func (self *Tile) EncodeToBytes(buffer []byte) []byte

func (*Tile) IsLandingFor

func (self *Tile) IsLandingFor(ctx *context.Context, carrots *carrot.Inventory, ox, fx, y int) bool

func (*Tile) RawRect

func (self *Tile) RawRect() image.Rectangle

func (*Tile) String

func (self *Tile) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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