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

81 lines
2.6 KiB
Go
Raw Normal View History

package animation
import (
2022-11-09 18:04:36 -08:00
"git.wisellama.rocks/Project-Ely/project-ely/internal/game/sprite"
rl "github.com/gen2brain/raylib-go/raylib"
)
2022-11-20 15:20:20 -08:00
var PenguinAnimations map[int]entityAnimation
const (
PENGUIN_WALK_RIGHT int = iota
PENGUIN_WALK_LEFT
2022-10-23 22:31:51 -07:00
PENGUIN_WALK_UP
PENGUIN_WALK_DOWN
PENGUIN_STATIONARY_RIGHT
PENGUIN_STATIONARY_LEFT
PENGUIN_STATIONARY_UP
PENGUIN_STATIONARY_DOWN
2022-10-23 22:31:51 -07:00
)
2022-10-13 15:37:22 -07:00
2022-10-23 22:31:51 -07:00
const (
PENGUIN_NUM_ANIMS = 8
2022-10-23 22:31:51 -07:00
PENGUIN_DEFAULT = PENGUIN_STATIONARY_RIGHT
)
func DefinePenguinAnimations() {
filename := sprite.DELILAHWALKING
var (
dimensions rl.Vector2
offset rl.Vector2
center rl.Vector2
length int
speed int
border int
)
dimensions = rl.Vector2{X: 13, Y: 17}
2022-11-20 15:20:20 -08:00
PenguinAnimations = make(map[int]entityAnimation)
2022-10-13 15:37:22 -07:00
// Walking Right is in the spritesheet.
speed = 5
offset = rl.Vector2{X: 0, Y: 1}
2022-10-23 22:31:51 -07:00
length = 5
2022-11-20 15:20:20 -08:00
border = 1 // optional border around each sprite
center = getCenter(dimensions) // center is for rotation, nil will default to w/2 h/2
2022-10-23 22:31:51 -07:00
walkRight := sprite.NewAnimation(filename, dimensions, offset, length, border)
PenguinAnimations[PENGUIN_WALK_RIGHT] = NewEntityAnimation(walkRight, speed, length, 0, center, FLIP_NONE)
2022-10-13 15:37:22 -07:00
// Walking Left is just that flipped.
PenguinAnimations[PENGUIN_WALK_LEFT] = NewEntityAnimation(walkRight, speed, length, 0, center, FLIP_HORIZONTAL)
2022-10-13 15:37:22 -07:00
// Stationary Right/Left is just the first frame.
2022-10-13 15:37:22 -07:00
length = 1
2022-10-23 22:31:51 -07:00
stationaryRight := sprite.NewAnimation(filename, dimensions, offset, length, border)
PenguinAnimations[PENGUIN_STATIONARY_RIGHT] = NewEntityAnimation(stationaryRight, speed, length, 0, center, FLIP_NONE)
PenguinAnimations[PENGUIN_STATIONARY_LEFT] = NewEntityAnimation(stationaryRight, speed, length, 0, center, FLIP_HORIZONTAL)
2022-10-23 22:31:51 -07:00
// Walk Up
length = 4
offset = rl.Vector2{X: 0, Y: 3}
2022-10-23 22:31:51 -07:00
walkUp := sprite.NewAnimation(filename, dimensions, offset, length, border)
PenguinAnimations[PENGUIN_WALK_UP] = NewEntityAnimation(walkUp, speed, length, 0, center, FLIP_NONE)
2022-10-23 22:31:51 -07:00
// Stationary Up
length = 1
stationaryUp := sprite.NewAnimation(filename, dimensions, offset, length, border)
PenguinAnimations[PENGUIN_STATIONARY_UP] = NewEntityAnimation(stationaryUp, speed, length, 0, center, FLIP_NONE)
2022-10-23 22:31:51 -07:00
// Walk Down
length = 4
offset = rl.Vector2{X: 0, Y: 0}
2022-10-23 22:31:51 -07:00
walkDown := sprite.NewAnimation(filename, dimensions, offset, length, border)
PenguinAnimations[PENGUIN_WALK_DOWN] = NewEntityAnimation(walkDown, speed, length, 0, center, FLIP_NONE)
// Stationary Down
length = 1
stationaryDown := sprite.NewAnimation(filename, dimensions, offset, length, border)
PenguinAnimations[PENGUIN_STATIONARY_DOWN] = NewEntityAnimation(stationaryDown, speed, length, 0, center, FLIP_NONE)
}