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:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user