holy crap click handling works too

This commit was merged in pull request #5.
This commit is contained in:
2025-08-29 22:58:06 -04:00
parent 4829fbb5c7
commit 430259475b
9 changed files with 173 additions and 119 deletions

View File

@@ -1,22 +1,15 @@
package elements
import (
"git.vezzani.net/ben/games/common/elements/v1/mouse"
"github.com/hajimehoshi/ebiten/v2"
)
type ElementFunc func(Bounds) Element
type Clickable interface {
}
type Mouseable interface {
}
type InitFunc func(Bounds) Element
type Element interface {
HandleMouseEvent(s mouse.State) bool
Size() (w, h float64)
Draw(image *ebiten.Image) (w, h float64)
Draw(image *ebiten.Image)
}
type Point struct {
@@ -27,3 +20,7 @@ type Bounds struct {
Min Point
Width, Height float64
}
func (b *Bounds) Contains(p Point) bool {
return p.X >= b.Min.X && p.X <= b.Min.X+b.Width && p.Y >= b.Min.Y && p.Y <= b.Min.Y+b.Height
}