package blocks import ( "image/color" "git.vezzani.net/ben/games/common/elements/v1" "git.vezzani.net/ben/games/common/elements/v1/mouse" "github.com/hajimehoshi/ebiten/v2" "github.com/hajimehoshi/ebiten/v2/vector" ) func New(ops ...OptFunc) elements.Element { b := Block{} for i := range ops { ops[i](&b) } return &b } type Block struct { elements.Core backgroundColor *color.Color mouse.NopHandler width, height int name string } func (b *Block) Bounds() elements.Bounds { return elements.Bounds{ Min: b.Anchor(), Width: b.width, Height: b.height, } } func (b *Block) Size() (w, h int) { return b.width, b.height } func (b *Block) Draw(image *ebiten.Image) { bnd := b.Bounds() if b.backgroundColor != nil { vector.DrawFilledRect( image, float32(b.Anchor().X), float32(b.Anchor().Y), float32(bnd.Width), float32(bnd.Height), *b.backgroundColor, true, ) } return }