Metroidvania game
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
849 B

9 months ago
package component
import (
"time"
8 months ago
"code.rocketnine.space/tslocum/monovania/engine"
9 months ago
"code.rocketnine.space/tslocum/gohan"
"github.com/hajimehoshi/ebiten/v2"
)
type SpriteComponent struct {
Image *ebiten.Image
HorizontalFlip bool
VerticalFlip bool
DiagonalFlip bool // TODO unimplemented
Overlay *ebiten.Image
OverlayX, OverlayY float64 // Overlay offset
Frame int
Frames []*ebiten.Image
FrameTime time.Duration
LastFrame time.Time
NumFrames int
OverrideColorScale bool
ColorScale float64
9 months ago
}
8 months ago
var SpriteComponentID = engine.Engine.NewComponentID()
9 months ago
func (p *SpriteComponent) ComponentID() gohan.ComponentID {
return SpriteComponentID
}
8 months ago
func Sprite(ctx *gohan.Context) *SpriteComponent {
c, ok := ctx.Component(SpriteComponentID).(*SpriteComponent)
9 months ago
if !ok {
return nil
}
return c
}