wip I guess

This commit is contained in:
2025-09-05 21:21:18 -04:00
parent 4e6d720a91
commit 9a4993570e
10 changed files with 143 additions and 112 deletions

View File

@@ -1,28 +1,27 @@
package blocks
import (
"image/color"
"git.vezzani.net/ben/games/common/elements/v1"
"git.vezzani.net/ben/games/common/elements/v1/mouse"
"git.vezzani.net/ben/games/common/elements/v1/base"
"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)
type Builder elements.Builder
func New(ops ...OptFunc) Builder {
return func() elements.Element {
b := Block{}
for i := range ops {
ops[i](&b)
}
return &b
}
return &b
}
type Block struct {
elements.Core
backgroundColor *color.Color
mouse.NopHandler
base.Element
width, height int
name string
}
@@ -41,7 +40,7 @@ func (b *Block) Size() (w, h int) {
func (b *Block) Draw(image *ebiten.Image) {
bnd := b.Bounds()
if b.backgroundColor != nil {
if b.BackgroundColor() != nil {
vector.DrawFilledRect(
image,
float32(b.Anchor().X),