While looking around for some HTML5 Canvas code, I found a lot of examples, but only a handful of reusable libraries. The drawing functions, are useful and there are draw image functions that draw a part of an image, useful for a sprite. Nice but it can get troublesome with tiled animation and transformations. In the end, I decided to make one myself: CanLaro!
Can: short for canvas, also "to be able to"
Laro: Tagalog word for game
My goal for this library is mainly to provide code that can help any 2D game get started as long as you know some Javascript and know what a game loop is. I wrote/am writing this mainly as a helper and you are free to write your game as you please.
Here it is in action: CanLaro Demo: BobCanvas.
At the moment, here's what it offers:
- Sprite
- multiple animations (different sets of frames per animation)
- transformation (rotation, translation, scale)
- alpha
- Keyboard Input Handler
- configurable key mapping
- key state checking (of course!)
- opposing keys
Check the README at the CanLaro github project repository for more details and updated documentation.
Planned possible updates:
- Resource Manager/Loader (there's code in there, but it still needs some work)
- Sprite Manager
- Audio Manager
- ...
