assets

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2023 License: MIT, MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Animate added in v0.3.0

func Animate(frame, tick int, ft FrameTags) int

Animate determines the next animation frame for a sprite

func LoadFont

func LoadFont(name string) *etxt.Font

Load a font for use with etxt specified by font name

func LoadImage

func LoadImage(name string) *ebiten.Image

Load an image from embedded FS into an ebiten Image object

func LoadSoundFile

func LoadSoundFile(name string, sampleRate int) *vorbis.Stream

Load an OGG Vorbis sound file with 44100 sample rate and return its stream

func NewMusicPlayer

func NewMusicPlayer(music *vorbis.Stream, context *audio.Context) *audio.Player

NewMusicPlayer loads a sound into an audio player that can be used to play it as an infinite loop of music without any additional setup required

func NewSoundPlayer

func NewSoundPlayer(audioFile *vorbis.Stream, context *audio.Context) *audio.Player

NewSoundPlayer loads a sound into an audio player that can be used to play it without any additional setup required

Types

type Frame

type Frame struct {
	Duration int           `json:"duration"`
	Position FramePosition `json:"frame"`
}

Frame is a single frame of an animation, usually a sub-image of a larger image containing several frames

type FramePosition

type FramePosition struct {
	X int `json:"x"`
	Y int `json:"y"`
	W int `json:"w"`
	H int `json:"h"`
}

FramePosition represents the position of a frame, including the top-left coordinates and its dimensions (width and height)

type FrameTags

type FrameTags struct {
	Name      string `json:"name"`
	From      int    `json:"from"`
	To        int    `json:"to"`
	Direction string `json:"direction"`
}

FrameTags contains tag data about frames to identify different parts of an animation, e.g. idle animation, jump animation frames etc.

type Frames

type Frames []Frame

Frames is a slice of frames used to create sprite animation

type Sound

type Sound struct {
	Audio      []*audio.Player
	LastPlayed int
	Volume     float64
}

Sound stores and plays all the sound variants for one single soundType

func (*Sound) AddMusic

func (s *Sound) AddMusic(f string, sampleRate int, context *audio.Context)

AddMusic adds one new music to the soundType

func (*Sound) AddSound

func (s *Sound) AddSound(f string, sampleRate int, context *audio.Context, v ...int)

AddSound adds one new sound to the soundType

func (*Sound) Pause

func (s *Sound) Pause()

Pause pauses the audio being played

func (*Sound) Play

func (s *Sound) Play()

Play plays the audio or a random one if there are more

func (*Sound) PlayVariant

func (s *Sound) PlayVariant(i int)

PlayVariant plays the selected audio

func (*Sound) SetVolume

func (s *Sound) SetVolume(v float64)

SetVolume sets the volume of the audio

type Sounds

type Sounds []*Sound

Sounds is a slice of sounds

type SpriteMeta

type SpriteMeta struct {
	ImageName string      `json:"image"`
	FrameTags []FrameTags `json:"frameTags"`
}

SpriteMeta contains sprite meta-data, basically everything except frame data

type SpriteSheet

type SpriteSheet struct {
	Sprite Frames     `json:"frames"`
	Meta   SpriteMeta `json:"meta"`
	Image  *ebiten.Image
}

SpriteSheet is the root-node of sprite data, it contains frames and meta data about them

func LoadSprite added in v0.3.0

func LoadSprite(name string) *SpriteSheet

Load a sprite image and associated meta-data given a file name (without extension)

Jump to

Keyboard shortcuts

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