https://github.com/cebarks/spriteplus
A simple spritesheet library for use with Pixel
https://github.com/cebarks/spriteplus
gamedev gamedev-library go golang graphics
Last synced: 5 months ago
JSON representation
A simple spritesheet library for use with Pixel
- Host: GitHub
- URL: https://github.com/cebarks/spriteplus
- Owner: cebarks
- License: gpl-3.0
- Created: 2021-03-25T01:48:21.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-10-18T22:40:38.000Z (about 2 years ago)
- Last Synced: 2025-06-27T21:58:25.318Z (6 months ago)
- Topics: gamedev, gamedev-library, go, golang, graphics
- Language: Go
- Homepage:
- Size: 37.1 KB
- Stars: 5
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# spriteplus
spriteplus is a golang library meant to be used along side the great [Pixel](https://github.com/faiface/pixel) library. It provides a generic SpriteSheet interface, and a few implementations.
---
## Installation
`go get github.com/cebarks/spriteplus`
---
## Usage
```golang
import "github.com/cebarks/spriteplus"
```
### Sprite Sheets
```golang
//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](https://choosealicense.com/licenses/gpl-3.0/)