Files
games/common/elements/v1/core/core.go
2025-09-06 09:32:53 -04:00

33 lines
581 B
Go

package core
import (
"git.vezzani.net/ben/games/common/elements/v1"
"git.vezzani.net/ben/games/common/elements/v1/mouse"
"git.vezzani.net/ben/games/common/geo"
)
type Element struct {
mouse.NopHandler
anchor geo.Point
children []elements.Element
name string // For debugging
}
func (c *Element) Anchor() geo.Point {
return c.anchor
}
func (c *Element) SetAnchor(a geo.Point) {
d := c.Anchor().Delta(a)
for _, ch := range c.Children() {
ch.SetAnchor(ch.Anchor().Add(d))
}
c.anchor = a
}
func (c *Element) Children() []elements.Element {
return c.children
}