Files
games/common/elements/v1/element.go

27 lines
424 B
Go

package elements
import (
"github.com/hajimehoshi/ebiten/v2"
)
type InitFunc func(Bounds) Element
type Element interface {
Size() (w, h float64)
Draw(image *ebiten.Image)
}
type Point struct {
X, Y float64
}
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
}