spriteutil

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2020 License: BSD-3-Clause Imports: 8 Imported by: 1

README

spriteutil

Just a few things for use with faiface/pixel 2D library

Animated GIF in Pixel

Using github.com/faiface/pixel we can display animated GIF images!

import (
    "github.com/aerth/spriteutil"
)

func run(){
// ...
sprite, err := spriteutil.LoadGif(file)
if err != nil { return err }
sprite.Update(dt)
sprite.Draw(win, pixel.IM)
// ...
}

Image/Font Credits:

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadTTF

func LoadTTF(rdr io.Reader, size float64, origin pixel.Vec) *text.Text

Types

type AnimatedSprite

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

AnimatedSprite holds gif frames and manages timing. don't forget to call `a.Update(dt)`

func LoadGif

func LoadGif(file io.Reader) (*AnimatedSprite, error)

LoadGif returns an AnimatedSprite

func (*AnimatedSprite) Draw

func (a *AnimatedSprite) Draw(t pixel.Target, m pixel.Matrix)

Draw a gif frame onto a target

func (*AnimatedSprite) Update

func (a *AnimatedSprite) Update(dt float64)

Update gif frame based on time that has passed since last call to Update Get dt in your mainloop like this: `dt = time.Since(last).Seconds()`

Jump to

Keyboard shortcuts

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