tile tweaks
This commit is contained in:
parent
27cbaf9403
commit
8ddfe28427
2 changed files with 10 additions and 4 deletions
|
@ -33,6 +33,9 @@ func (t *Tilemap) Draw(screen *ebiten.Image, geom ebiten.GeoM) {
|
|||
geom.Concat(*t.Transform.GeoM())
|
||||
for j, row := range t.Map {
|
||||
for i, tile := range row {
|
||||
if tile == nil {
|
||||
continue
|
||||
}
|
||||
var op ebiten.DrawImageOptions
|
||||
op.GeoM.Translate(float64(i*t.TileSize), float64(j*t.TileSize))
|
||||
op.GeoM.Concat(geom)
|
||||
|
@ -49,10 +52,10 @@ func (t *Tilemap) Update() error {
|
|||
if t.Disabled {
|
||||
return nil
|
||||
}
|
||||
for j := range t.Map {
|
||||
for i := range t.Map[j] {
|
||||
if tile, ok := t.Map[j][i].(Updater); ok {
|
||||
if err := tile.Update(); err != nil {
|
||||
for _, row := range t.Map {
|
||||
for _, tile := range row {
|
||||
if u, ok := tile.(Updater); ok {
|
||||
if err := u.Update(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
|
3
main.go
3
main.go
|
@ -69,6 +69,9 @@ func main() {
|
|||
tiles[6][7] = &engine.AnimatedTile{
|
||||
AnimRef: engine.AnimRef{Key: "red_tiles"},
|
||||
}
|
||||
tiles[2][8] = &engine.AnimatedTile{
|
||||
AnimRef: engine.AnimRef{Key: "green_tiles"},
|
||||
}
|
||||
|
||||
game := &engine.Game{
|
||||
ScreenHeight: screenHeight,
|
||||
|
|
Loading…
Reference in a new issue