examples/tiles: improve readability by calculating tileXNum on the fly

This commit is contained in:
Hajime Hoshi 2022-06-10 23:54:45 +09:00
parent 826afcb9cc
commit 4836266c2b

View File

@ -36,7 +36,6 @@ const (
const ( const (
tileSize = 16 tileSize = 16
tileXNum = 25
) )
var ( var (
@ -64,6 +63,9 @@ func (g *Game) Update() error {
} }
func (g *Game) Draw(screen *ebiten.Image) { func (g *Game) Draw(screen *ebiten.Image) {
w, _ := tilesImage.Size()
tileXNum := w / tileSize
// Draw each tile with each DrawImage call. // Draw each tile with each DrawImage call.
// As the source images of all DrawImage calls are always same, // As the source images of all DrawImage calls are always same,
// this rendering is done very efficiently. // this rendering is done very efficiently.