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())
|
geom.Concat(*t.Transform.GeoM())
|
||||||
for j, row := range t.Map {
|
for j, row := range t.Map {
|
||||||
for i, tile := range row {
|
for i, tile := range row {
|
||||||
|
if tile == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
var op ebiten.DrawImageOptions
|
var op ebiten.DrawImageOptions
|
||||||
op.GeoM.Translate(float64(i*t.TileSize), float64(j*t.TileSize))
|
op.GeoM.Translate(float64(i*t.TileSize), float64(j*t.TileSize))
|
||||||
op.GeoM.Concat(geom)
|
op.GeoM.Concat(geom)
|
||||||
|
@ -49,10 +52,10 @@ func (t *Tilemap) Update() error {
|
||||||
if t.Disabled {
|
if t.Disabled {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
for j := range t.Map {
|
for _, row := range t.Map {
|
||||||
for i := range t.Map[j] {
|
for _, tile := range row {
|
||||||
if tile, ok := t.Map[j][i].(Updater); ok {
|
if u, ok := tile.(Updater); ok {
|
||||||
if err := tile.Update(); err != nil {
|
if err := u.Update(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
3
main.go
3
main.go
|
@ -69,6 +69,9 @@ func main() {
|
||||||
tiles[6][7] = &engine.AnimatedTile{
|
tiles[6][7] = &engine.AnimatedTile{
|
||||||
AnimRef: engine.AnimRef{Key: "red_tiles"},
|
AnimRef: engine.AnimRef{Key: "red_tiles"},
|
||||||
}
|
}
|
||||||
|
tiles[2][8] = &engine.AnimatedTile{
|
||||||
|
AnimRef: engine.AnimRef{Key: "green_tiles"},
|
||||||
|
}
|
||||||
|
|
||||||
game := &engine.Game{
|
game := &engine.Game{
|
||||||
ScreenHeight: screenHeight,
|
ScreenHeight: screenHeight,
|
||||||
|
|
Loading…
Reference in a new issue