enhanced doc, fixed drawing when zooming or moving canvas

This commit is contained in:
2024-05-23 15:23:06 +02:00
parent ab51a27b4c
commit 8241cf83f2
2 changed files with 34 additions and 16 deletions

View File

@@ -243,9 +243,10 @@ func (game *Game) Update() error {
// set a cell to alive or dead
func (game *Game) ToggleCellOnCursorPos(alive int) {
xPX, yPX := ebiten.CursorPosition()
x := xPX / game.Cellsize
y := yPX / game.Cellsize
// use cursor pos relative to the world
worldX, worldY := game.Camera.ScreenToWorld(ebiten.CursorPosition())
x := int(worldX) / game.Cellsize
y := int(worldY) / game.Cellsize
//fmt.Printf("cell at %d,%d\n", x, y)