Provides a set of default code that makes getting up and running with an HTML5 canvas game very easy.
This project makes starting an interactive 2D Canvas application fast and easy, even for developers who have never used Canvas before.
Thorough documentation is an explicit goal of this project. It should be easy to learn, use, and get started.
First, fork and
git clonethis repository, or install from NPM with
npm i canvasboilerplate.
To get started building, open up main.js. There are three functions there which are the backbone of your application:
These functions are called automatically for you. Just fill in the logic! To see your project, open index.html in your browser. By default, it has a keyboard-controlled player who can wander around.
At this point you can dive in and start building right away, explore more features, or dig deeper into the documentation:
You can also read a complete overview of everything this project provides.
H5CGB is a good choice if you just want to get going quickly without learning a bunch of opinioniated, engine-specific APIs, or if you are mainly interested in avoiding setup but want control over the details. Sometimes game engines are just overkill, or too overwhelming to learn, or try to do too much for you.
This project is MIT-licensed.
Compatible with all modern browsers, meaning not IE8. Also works in modern mobile browsers as long as you accommodate mobile input methods. The Paint demo is a good example of this.
Contributions are welcome!
I'd love to hear what you make!
Many other people wrote jQuery, classes.js, console-extras.js, stats.js, and parts of jQuery.hotkeys; they are credited in their respective files. Additionally, many people contributed to H5BP, from which most of the HTML and CSS, .htaccess, and robots.txt rules originated. Thanks also to JSDuck for providing the framework for the documentation site, and to Atari for the original image used to derive the centipede example sprite.