holy crap click handling works too
This commit was merged in pull request #5.
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user