Fix some errors in iso->pix->iso conversions, add debugging

Maps now render a bit more properly, and our mouse position can be
correctly assigned to a cell. Kind of, mostly.
This commit is contained in:
2020-04-18 00:12:15 +01:00
parent 1e141a2fb9
commit 6e70ddcb60
8 changed files with 156 additions and 23 deletions

View File

@@ -0,0 +1,25 @@
package scenario
import (
// "image"
"github.com/hajimehoshi/ebiten"
"code.ur.gs/lupine/ordoor/internal/maps"
)
type CellPoint struct {
IsoPt
Z int
}
func (s *Scenario) CellAtCursor() (maps.Cell, CellPoint) {
x, y := ebiten.CursorPosition()
screenPos := CartPt{X: float64(s.Viewpoint.X + x), Y: float64(s.Viewpoint.Y + y)}
isoPos := screenPos.ToISO()
// Convert to cell coordinates.
// TODO: zoom support will need a camera
// FIXME: adjust for Z level
return s.area.Cell(int(isoPos.X), int(isoPos.Y), 0), CellPoint{IsoPt: isoPos, Z: s.ZIdx}
}