Animate a tile
This commit is contained in:
parent
259747a89c
commit
76bcda2df5
2 changed files with 17 additions and 2 deletions
|
@ -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
15
main.go
|
@ -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),
|
||||
|
|
Loading…
Reference in a new issue