mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
examples/tiles: improve readability by calculating tileXNum on the fly
This commit is contained in:
parent
826afcb9cc
commit
4836266c2b
@ -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.
|
||||||
|
Loading…
Reference in New Issue
Block a user