Code archive for the book HTML5 Games: Novice to Ninja
Hello and thanks for checking out HTML5 Games: Novice to Ninja! These are the code examples for the book. If you are reading this then you are among the first people in the world getting your hands dirty. If you have issues running the examples, find any inconsistencies and errors, or you have suggestions then please either log an issue or email me at [email protected] (or ping me @mrspeaker), I will try to help.
They will run in all recent browsers - check out all the examples and play some of the games!
To modify the code and make your own game you'll need to be able to run it. Each example also includes an npm
package.jsonfile for converting the code into a single file that can be run in any browser. For each example you need to run:
You only have to do this once per example. This installs all the dependencies and files needed to run and package your game. Use the command:
It will start a webserver (at the URL http://localhost:9966/ by default). You can test your changes at the URL.
Once you've finished your game and are happy with your changes, you can run:
npm run build
Which will convert the code into a single
build.jsfile that can be run with the included
index.htmlfile. These two files (along with any of your game assets and images) can then be deployed to a public server for everyone to play. If you make a game, please let me know on Twitter (@mrspeaker)!
(For Firefox before version 60 it's enabled behind the about:config
file://- so you can't just double-click and run it. There is a webserver in the root directory (that is, in
html5games1/) that you can install and run (via
npm install npm start
This will run a server on http://localhost:9966/. If you browse here there will be links to each example.
I'm organizing the code for each chapter. There's still a little tidying going on. Also, still remaining: