Animate a tile

This commit is contained in:
Josh Deprez 2021-07-29 15:29:26 +10:00 committed by Josh Deprez
parent 259747a89c
commit 76bcda2df5
2 changed files with 17 additions and 2 deletions

View file

@ -51,8 +51,8 @@ type StaticTile int
func (s StaticTile) TileIndex() int { return int(s) }
type AnimatedTile struct {
Frame int // if Tile in AnimationDefs, index
DurationTicks int // time spent showing this frame
Frame int // index into AnimDef
DurationTicks int // time spent showing current frame
AnimDef []TileAnimFrameDef
}

15
main.go
View file

@ -55,6 +55,21 @@ func main() {
}
}
tiles[3][5] = &engine.AnimatedTile{
AnimDef: []engine.TileAnimFrameDef{
{Tile: 0, DurationTicks: 15},
{Tile: 1, DurationTicks: 15},
{Tile: 2, DurationTicks: 15},
{Tile: 3, DurationTicks: 15},
{Tile: 4, DurationTicks: 15},
{Tile: 5, DurationTicks: 15},
{Tile: 6, DurationTicks: 15},
{Tile: 7, DurationTicks: 15},
{Tile: 8, DurationTicks: 15},
{Tile: 9, DurationTicks: 15},
},
}
tilemap := &engine.Tilemap{
Map: tiles,
Src: ebiten.NewImageFromImage(boxesPNG),