gg/object.go

89 lines
1.7 KiB
Go
Raw Normal View History

2023-10-23 15:45:18 +03:00
package gg
2023-02-17 12:47:17 +03:00
// Implementing the interface type
// will call the function OnStart
// when first appear on scene BEFORE
// the OnUpdate.
2023-05-26 18:31:04 +03:00
// The v value will be get from Add function.
type Starter interface {
Start(*Context)
2023-02-17 12:47:17 +03:00
}
// Implementing the interface type
// will call the function on each
// engine iteration.
type Updater interface {
2023-12-23 00:09:07 +03:00
Update(*Context)
2023-02-17 12:47:17 +03:00
}
2023-05-26 18:31:04 +03:00
// Implementing the interface type
// will call the function on deleting
// the object.
type Deleter interface {
Delete(*Context)
2023-02-17 12:47:17 +03:00
}
type Antialiasity struct {
Antialias bool
}
// Feat to embed for turning visibility on and off.
type Visibility struct {
Visible bool
}
func (v Visibility) IsVisible() bool {
return v.Visible
}
// Feat to embed to make colorful objects.
type Colority struct {
Color Color
}
// The interface describes anything that can be
// drawn. It will be drew corresponding to
// the layers order so the layer must be returned.
type Drawer interface {
Draw(*Context) []EVertex
GetLayer() Layer
IsVisible() bool
}
type Objecter interface {
GetObject() *Object
Input() chan *Context
Starter
Updater
Collider
Resolver
Drawer
Deleter
}
// The type for embedding into engine-in types.
type Object struct {
Collidability
Resolvability
Layer
Visibility
input chan *Context
}
func (o *Object) GetObject() *Object { return o }
func (o *Object) Input() chan *Context { return o.input }
func (o *Object) Start(c *Context) {}
func (o *Object) Update(c *Context) {}
func (o *Object) ContainedPoints(Points) Points {return Points{}}
func (o *Object) Vertices() Vertices {return Vertices{}}
func (o *Object) Edges() Edges {return Edges{}}
func (o *Object) Resolve(c *Context) {}
func (o *Object) Draw(c *Context) []EVertex { return nil}
func (o *Object) Delete(c *Context) {}