Skip to content

A basic sprite library that supports both animated and static sprites for p5.js

License

Notifications You must be signed in to change notification settings

RandomGamingDev/p5.Sprite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

p5.Sprite

A basic sprite library that supports both animated and static sprites for p5.js

Create a new instance with constructor(atlas, sprites, pos, size, speed). atlas is simply the texture, sprites the sprites in the format of a list containing more lists of format [x, y, w, h] (this is the part of the atlas that will be drawn), pos the position (top left) of the sprite in a list of format [x, y], size the size in a format of [w, h] (width and height), and speed being how fast the sprite changes from one to another in the animation. Remember when animation that the progress is normalized from 0-1 when choosing your speed.

An example is available with its full source in https://github.com/RandomGamingDev/p5.Sprite/tree/main/example and its result is viewable here

To draw the sprite simply call sprite.tick(useDeltatime) with useDeltatime being a boolean that's true when you want to use deltaTime and false when you don't.

This library requires you to import AnimatorJs. To import this library you can either manually import it by adding the animator.js file to your own website or import it via the cdn: https://cdn.jsdelivr.net/gh/RandomGamingDev/p5.Sprite/sprite.js.

About

A basic sprite library that supports both animated and static sprites for p5.js

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published