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

@@ -35,6 +35,7 @@ type Window struct {
Title string
KeyUpHandlers map[ebiten.Key]func()
MouseWheelHandler func(float64, float64)
MouseClickHandler func()
// Allow the "game" to be switched out at any time
game Game
@@ -72,6 +73,10 @@ func (w *Window) OnMouseWheel(f func(x, y float64)) {
w.MouseWheelHandler = f
}
func (w *Window) OnMouseClick(f func()) {
w.MouseClickHandler = f
}
func (w *Window) Layout(_, _ int) (int, int) {
return w.xRes, w.yRes
}
@@ -130,6 +135,12 @@ func (w *Window) Update(screen *ebiten.Image) (outErr error) {
}
}
if w.MouseClickHandler != nil {
if inpututil.IsMouseButtonJustPressed(ebiten.MouseButtonLeft) {
w.MouseClickHandler()
}
}
if ebiten.IsDrawingSkipped() {
return nil
}