wip I guess
This commit is contained in:
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user