Pro HTML5 Games – The Second Edition

A long time back in early 2012, I was asked by Apress to write a book on game programming. I decided at the time to write a book that shared some of my experience and knowledge from building an RTS game – the HTML5 version of Command and Conquer, and this became Pro HTML5 Games. I briefly wrote about the book in a detailed article describing the story of the first edition of Pro HTML5 Games.


If you are interested, you can also play Command and Conquer – HTML5 over here.

Nearly half a decade after I wrote Pro HTML5 Games, in 2017, I was approached by my editor at Apress and asked if I would consider writing a second edition.

I wasn’t completely sure at first, because I considered the first edition fairly complete in itself and I didn’t want to write a second edition just for the sake of writing a second edition.

I only wanted to take on the task of writing a second edition if I could provide enough value in the second edition where I could justify the effort involved by everyone.

Luckily all the readers of the first edition who, over the years, reached out to me with questions and feedback or left reviews for the book came to the rescue.

Between the mails and notes, I had enough ideas for corrections and improvements that new readers would find extremely helpful.

This included detailed explanations in tons of sections where readers had doubts, expanded code where readers had tried to expand game functionality but had got stuck and needed help, and finally an improved rewrite of the text to help guide readers through the code.

One thing I definitely wanted to do based on one of the first reviews I received was to remove the jQuery dependency in the games. The games have been completely rewritten to no longer require jQuery or any of the HTML5 shims that had been necessary at the time of writing the first edition. This makes the code much more clean and streamlined.

Now that HTML5 is completely supported by most mobiles, the games in the second edition have also been completely rewritten to work as responsive mobile games with automatic adjusting of aspect ratio as well as resolution, touch event support, and audio support using WebAudio. The WebAudio support means games work even on devices where HTML5 Audio doesn’t work (such as iOS devices).

Please note that the games are the same ones in the first edition of Pro HTML5 Games. The second edition cleans up the artwork and code and adds significant functionality, however the games themselves remain the same.


The first game in the book, Froot Wars, is a Box2D Engine based game similar to the very popular Angry Birds.

In the process of creating this game, we look at building splash screens, game menus, levels and an asset loader to load sounds and images. We then have a detailed look at the Box2DWeb engine and how to use the engine to manage the game physics. Finally, we integrate the physics engine into our game, add sound and background music to build a complete game. You can play Froot Wars here.

The second game in the book, Last Colony, is an RTS game with both a single player campaign mode as well as a multiplayer mode. I’d like to specifically thank Daniel Cook (, who graciously shared the artwork from one of his earlier game projects for use in this book.

The single player campaign includes an economy with buildings, vehicles, aircraft along with an over arching storyline told using scripted events. We look at adding intelligent unit movement using pathfinding and steering, and combat using a combination of scripted events, and finite state machines.

We then look at adding multiplayer using the WebSocket API and Node.JS. We look at everything from the basics of WebSocket and Node.JS, to details such as compensating for network latency while keeping the player games synchronized.

You can play Last Colony here.

In addition to the extra mobile chapters, there is also one final extra chapter where I share best practices and thoughts of my own based on several years working as a consultant in the HTML5 games development and web/web-app development industry. I hope that you find some of these insights helpful in your own game programming journey.

The second edition is a much better representation of what I would have liked the first edition to be. Looking back, I’m glad that I took on this second edition even though it was an incredibly exhausting task.

Overall, if you have already read the first edition of the book, you might not necessarily need to buy the second edition. However, if you are recommending the book to a friend, you might as well have them pick the second edition (and the borrow the book to read the extra chapters if you feel so inclined).

You and your friends can purchase Pro HTML5 Games – 2nd Edition on Amazon HERE.

If you happen to have read either of the editions, I would appreciate your leaving a review on Amazon for future readers (and for me) to read.

Thank you for all your support. I do hope you find my book useful.

I wish you all the best in in your own game programming journey.