30 lines
444 B
Go
30 lines
444 B
Go
package land
|
|
|
|
import "github.com/veandco/go-sdl2/sdl"
|
|
|
|
type Object interface {
|
|
Create()
|
|
Update()
|
|
}
|
|
|
|
type DrawableObject interface {
|
|
Draw(pen *sdl.Renderer)
|
|
}
|
|
|
|
type BaseObject struct {
|
|
Children []Object
|
|
}
|
|
|
|
func (p *BaseObject) Create() {}
|
|
|
|
func (p *BaseObject) Update() {
|
|
// Update each child
|
|
for _, child := range p.Children {
|
|
child.Update()
|
|
}
|
|
}
|
|
|
|
func (p *BaseObject) AddChild(child Object) {
|
|
p.Children = append(p.Children, child)
|
|
}
|