canvas

package
v0.0.0-...-de431f0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyTerrainDiff

func ApplyTerrainDiff(c TerrainContext, prevState rpg2d.WorldState, diff rpg2d.WorldStateDiff) error

Taking a previous world state and a diff to the next state, this function will call the terrain context with the necessary steps to apply the diff and update the painting of the canvas.

Types

type TerrainContext

type TerrainContext interface {
	// Used if the bounds of the diff does NOT
	// have any overlap with the bounds of the
	// previous state.
	Reset(rpg2d.TerrainMapStateSlice)

	// Shift should expect A direction the canvas
	// should be shifted to maintian the tiles that
	// have already been drawn to it.
	// The magnitude is the number of tiles it should
	// be shifted for each direction.
	Shift(TerrainShift, TerrainShiftMagnitudes)

	// DrawTile should expect a terrain type for
	// the tile and a cell with the absolute coord
	// where the cell should be drawn.
	DrawTile(rpg2d.TerrainType, coord.Cell)
}

type TerrainShift

type TerrainShift int
const (
	TS_NORTH TerrainShift = iota
	TS_NORTHEAST
	TS_EAST
	TS_SOUTHEAST
	TS_SOUTH
	TS_SOUTHWEST
	TS_WEST
	TS_NORTHWEST
)

func (TerrainShift) String

func (i TerrainShift) String() string

type TerrainShiftMagnitudes

type TerrainShiftMagnitudes map[coord.Direction]int

Jump to

Keyboard shortcuts

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