From 4836266c2bf7a56b019cfa906390b8613dd70134 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Fri, 10 Jun 2022 23:54:45 +0900 Subject: [PATCH] examples/tiles: improve readability by calculating tileXNum on the fly --- examples/tiles/main.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/tiles/main.go b/examples/tiles/main.go index ad0b5f8f9..ca2b2a187 100644 --- a/examples/tiles/main.go +++ b/examples/tiles/main.go @@ -36,7 +36,6 @@ const ( const ( tileSize = 16 - tileXNum = 25 ) var ( @@ -64,6 +63,9 @@ func (g *Game) Update() error { } func (g *Game) Draw(screen *ebiten.Image) { + w, _ := tilesImage.Size() + tileXNum := w / tileSize + // Draw each tile with each DrawImage call. // As the source images of all DrawImage calls are always same, // this rendering is done very efficiently.