gg/animation.go

34 lines
529 B
Go

package gg
import (
"time"
)
type Animation struct {
Frames []*Image
}
type AnimationId int
type AnimationSet map[AnimationId] *Animation
// The type implements animated sprites.
type AnimatedSprite struct {
Sprite
Animations AnimationSet
AnimationId AnimationId
CurrentFrame int
TimeBetweenFrames time.Duration
}
func (as *AnimatedSprite) Animate(id AnimationId) bool {
_, ok := as.Animations[id]
if ok {
as.AnimationId = id
}
return ok
}
func (as *AnimatedSprite) Draw(c *Context) []EVertex {
return nil
}