project-ely/internal/game/entity/animation/penguin_animations.go

50 lines
1.5 KiB
Go

package animation
import (
"gitea.wisellama.rocks/Project-Ely/project-ely/internal/game/sprite"
"github.com/veandco/go-sdl2/sdl"
)
var PenguinAnimations map[int]*entityAnimation
const (
PENGUIN_WALK_RIGHT int = iota
PENGUIN_WALK_LEFT
PENGUIN_STATIONARY_RIGHT
PENGUIN_STATIONARY_LEFT
PENGUIN_DEFAULT = PENGUIN_STATIONARY_RIGHT
)
func DefinePenguinAnimations() {
filename := sprite.PLATFORMER_FOREST_CHARACTERS
var (
dimensions sdl.Point
offset sdl.Point
center *sdl.Point
length int32
speed int32
)
dimensions = sdl.Point{X: 32, Y: 32}
PenguinAnimations = make(map[int]*entityAnimation)
// Walking Right is in the spritesheet.
speed = 5
offset = sdl.Point{X: 0, Y: 2}
length = 4
center = nil // center is for rotation, nil will default to w/2 h/2
walkRight := sprite.NewAnimation(filename, dimensions, offset, length)
PenguinAnimations[PENGUIN_WALK_RIGHT] = NewEntityAnimation(walkRight, speed, length, 0, center, sdl.FLIP_NONE)
// Walking Left is just that flipped.
PenguinAnimations[PENGUIN_WALK_LEFT] = NewEntityAnimation(walkRight, speed, length, 0, center, sdl.FLIP_HORIZONTAL)
// Stationary is just the first frame.
length = 1
stationaryRight := sprite.NewAnimation(filename, dimensions, offset, length)
PenguinAnimations[PENGUIN_STATIONARY_RIGHT] = NewEntityAnimation(stationaryRight, speed, length, 0, center, sdl.FLIP_NONE)
PenguinAnimations[PENGUIN_STATIONARY_LEFT] = NewEntityAnimation(stationaryRight, speed, length, 0, center, sdl.FLIP_HORIZONTAL)
}