Categorygithub.com/cebarks/spriteplus
modulepackage
0.5.2
Repository: https://github.com/cebarks/spriteplus.git
Documentation: pkg.go.dev

# README

spriteplus

spriteplus is a golang library meant to be used along side the great Pixel library. It provides a generic SpriteSheet interface, and a few implementations.


Installation

go get github.com/cebarks/spriteplus


Usage

import "github.com/cebarks/spriteplus"

Sprite Sheets

//Create your sheet
sheet := spriteplus.NewSpriteSheet(false)

//Add your sprites to the sheet
err := sheet.AddSprite(gopherSprite, "gopher")
if err != nil {
  ...
}

//Optimize the texture
sheet.Optimize()


//These can be directly drawn to a Window (or any pixel.Target)
sprite := sheet.GetSprite("gopher") 
sprite.Draw(win, pixel.IM)

// or you can efficiently draw them using a batch with sheet.SourcePic()
pic := sheet.SourcePic()
batch := pixel.NewBatch(&pixel.TrianglesData{}, pic)

sprite.Draw(batch, pixel.IM)


batch.Draw(win, pixel.IM)

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.


License

GNU GPLv3

# Packages

No description provided by the author

# Functions

MakeAnimation builds an animation from the given sprite sprites and frame lengths.
MakeAnimationFromSheet builds an animation using sprites pulled from the given spritesheet using the given ids and frame lengths.
NewSpriteSheet creates a new instatiated sprite sheet.
Subimage returns a subimage of the given image.Image.
SubimageRect returns a subimage of the given image.Image.

# Structs

Animation is a series of sprites that change after a certain number of frames in sequential order.
SpriteSheet.