Giter VIP home page Giter VIP logo

spriteplus's Introduction

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

spriteplus's People

Contributors

bencarrr avatar cebarks avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

spriteplus's Issues

MakeAnimation always returns nil value

Hi there! I got stucked with MakeAnimation func as it is always returning nil value.

I've tried to make some really simple and basic thing like this:

       p1, _ := loadPicture("01.png")
	p2, _ := loadPicture("02.png")
	sprite1 :=  pixel.NewSprite(p1, p1.Bounds())
	sprite2 :=  pixel.NewSprite(p2, p2.Bounds())

	var Sprites []*pixel.Sprite

	Sprites = append(Sprites, sprite1, sprite2)

	anim, _ := spriteplus.MakeAnimation(Sprites, 2)
	fmt.Println("debug output is:", anim)
	anim.Draw(win, pixel.IM.Moved(win.Bounds().Center()))

debug output is: <nil>

=(

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.