26 lines
562 B
Go
26 lines
562 B
Go
|
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}
|
||
|
}
|