animation

package
v0.0.0-...-7a6bf91 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 14, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	FileSystem = os.DirFS(".")

	SHEET_CACHE              = make(map[string]*ebiten.Image)          // We never unload cached data yet, but if need be we can just clear this variable
	ANIMATION_MAP_CACHE      = make(map[string](map[string]Animation)) // We cache the full maps too to save on json parsing and file reading
	META_ANIMATION_MAP_CACHE = make(map[string](map[string]MetaAnimationList))
)

Functions

func LoadAnimationMap

func LoadAnimationMap(path string) (map[string]Animation, error)

func LoadMetaAnimationMap

func LoadMetaAnimationMap(path string) (map[string]MetaAnimationList, error)

func NewEbitenImage

func NewEbitenImage(path string) *ebiten.Image

Types

type Animation

type Animation struct {
	Sheet *ebiten.Image
	// contains filtered or unexported fields
}

func NewAnimationFromDefinition

func NewAnimationFromDefinition(def AnimationDefinition, parent_path string) Animation

func (Animation) Draw

func (anim Animation) Draw(target *ebiten.Image, xpos, ypos, scale, time float64)

TODO: currently animations are always drawn with the origin at the bottom middle of the sprite, give other options TODO: need to have draw methods actually just add to a depth sorted queue to draw with later, so we can meaningfully have a zpos

func (Animation) GetFrameRect

func (anim Animation) GetFrameRect(time float64) image.Rectangle

func (Animation) GetHMirror

func (anim Animation) GetHMirror(time float64) bool

func (Animation) GetHScale

func (anim Animation) GetHScale(time float64) float64

func (Animation) GetLength

func (anim Animation) GetLength() float64

func (Animation) GetRotation

func (anim Animation) GetRotation(time float64) float64

func (Animation) GetWMirror

func (anim Animation) GetWMirror(time float64) bool

func (Animation) GetWScale

func (anim Animation) GetWScale(time float64) float64

func (Animation) GetXOffset

func (anim Animation) GetXOffset(time float64) float64

func (Animation) GetYOffset

func (anim Animation) GetYOffset(time float64) float64

type AnimationDefinition

type AnimationDefinition struct {
	SheetPath    string `json:"sheet_path"`
	FrameWidth   int    `json:"frame_width"`
	FrameHeight  int    `json:"frame_height"`
	FrameOffsetX int    `json:"frame_offset_x"`
	FrameOffsetY int    `json:"frame_offset_y"`

	Length    float64            `json:"length"`
	Frames    map[string]int     `json:"frames"`
	XOffsets  map[string]float64 `json:"x_offsets"`
	YOffsets  map[string]float64 `json:"y_offsets"`
	WScales   map[string]float64 `json:"w_scales"`
	HScales   map[string]float64 `json:"h_scales"`
	WMirrors  map[string]bool    `json:"w_mirrors"`
	HMirrors  map[string]bool    `json:"h_mirrors"`
	Rotations map[string]float64 `json:"rotations"`
}

type AnimationMapDefinition

type AnimationMapDefinition struct {
	Animations map[string]AnimationDefinition `json:"animations"`
}

type AnimationPlayer

type AnimationPlayer struct {
	// contains filtered or unexported fields
}

func NewAnimationPlayer

func NewAnimationPlayer(anim PlayableAnimation, xpos, ypos, scale, time float64) AnimationPlayer

func (AnimationPlayer) Draw

func (p AnimationPlayer) Draw(target *ebiten.Image, time float64) bool

type Font

type Font struct {
	Animations      []Animation
	CharacterWidth  int
	CharacterHeight int
}

func NewFont

func NewFont(image_path string, char_w, char_h, char_per_line, height int) (Font, error)

func (Font) DrawText

func (font Font) DrawText(target *ebiten.Image, xpos, ypos, scale, time float64, runes []rune)

type MetaAnimation

type MetaAnimation struct {
	// contains filtered or unexported fields
}

func (MetaAnimation) Draw

func (anim MetaAnimation) Draw(target *ebiten.Image, xpos, ypos, scale, time float64)

func (MetaAnimation) GetAnimName

func (anim MetaAnimation) GetAnimName(time float64) string

func (MetaAnimation) GetLength

func (anim MetaAnimation) GetLength() float64

func (MetaAnimation) GetScale

func (anim MetaAnimation) GetScale(time float64) float64

func (MetaAnimation) GetTime

func (anim MetaAnimation) GetTime(time float64) float64

func (MetaAnimation) GetXOffset

func (anim MetaAnimation) GetXOffset(time float64) float64

func (MetaAnimation) GetYOffset

func (anim MetaAnimation) GetYOffset(time float64) float64

type MetaAnimationDefinition

type MetaAnimationDefinition struct {
	Length    float64            `json:"length"`
	AnimNames map[string]string  `json:"anim_names"`
	XOffsets  map[string]float64 `json:"x_offsets"`
	YOffsets  map[string]float64 `json:"y_offsets"`
	Scales    map[string]float64 `json:"scales"`
	Times     map[string]float64 `json:"times"` // currently just functions as a time offset
}

type MetaAnimationList

type MetaAnimationList struct {
	// contains filtered or unexported fields
}

func NewMetaAnimationFromDefinition

func NewMetaAnimationFromDefinition(defs []MetaAnimationDefinition, parent_path string, anims map[string]Animation) MetaAnimationList

func (MetaAnimationList) Draw

func (m MetaAnimationList) Draw(target *ebiten.Image, xpos, ypos, scale, time float64)

func (MetaAnimationList) GetLength

func (m MetaAnimationList) GetLength() float64

type MetaAnimationMapDefinition

type MetaAnimationMapDefinition struct {
	AnimationsPath string                               `json:"animations_path"`
	MetaAnimations map[string][]MetaAnimationDefinition `json:"meta_animations"`
}

type PlayableAnimation

type PlayableAnimation interface {
	Draw(*ebiten.Image, float64, float64, float64, float64)
	GetLength() float64
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL