-
Notifications
You must be signed in to change notification settings - Fork 0
/
components.go
38 lines (28 loc) · 896 Bytes
/
components.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package ecsexample
import (
"github.com/hajimehoshi/ebiten/v2"
)
// ComponentType defines the supported component types in a user readable format
type ComponentType string
const (
AnimationType ComponentType = "ANIMATION"
SpriteType ComponentType = "SPRITE"
TransformType ComponentType = "TRANSFORM"
)
// ComponentTyper returns the type of a component
type ComponentTyper interface{ Type() ComponentType }
type TransformComponent struct {
PosX, PosY float64
}
func (t *TransformComponent) Type() ComponentType { return TransformType }
type SpriteComponent struct {
Image *ebiten.Image
}
func (t *SpriteComponent) Type() ComponentType { return SpriteType }
type AnimationComponent struct {
Frames []*ebiten.Image
CurrentFrameIndex int
Count float64
AnimationSpeed float64
}
func (a AnimationComponent) Type() ComponentType { return AnimationType }