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

50 lines
1.6 KiB
Go

package entity
import (
"gitea.wisellama.rocks/Project-Ely/project-ely/internal/game/sprite"
"github.com/veandco/go-sdl2/sdl"
)
var penguinAnimations map[string]*entityAnimation
const (
PENGUIN_WALK_RIGHT = "walk-right"
PENGUIN_WALK_LEFT = "walk-left"
PENGUIN_STATIONARY_RIGHT = "stationary-right"
PENGUIN_STATIONARY_LEFT = "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[string]*entityAnimation)
// Walking Right is in the spritesheet.
speed = 10
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)
}