Creating an HTML5 Game
I’ve been meaning to write something about this for a long time! Over the summer we created Agent 008 Ball, a spy-themed HTML5 pool game. Creating it was a blast! We put a little video together to talk about the design process. You can check it out below. Also, here’s the case study for the project.
I’ve also been meaning to share a little bit about what we learned along the way. In addition to being a fun design challenge, 008 Ball brought plenty of technical challenges. It also forced us to do some thinking about HTML5 and the future of UI technologies.
What’s so HTML5 About This?
First of all, HTML5 is quickly becoming an overloaded / catch-all term. In fact, let’s just cut to the chase and call it it Web3.0.com. The truth is that a lot of 008 ball is really just modern browser awesomeness: jQuery and a cool javascript physics engine. Having said that, actual HTML5 features were required to make it happen, specifically:
- All of the ball rendering happens in a Canvas. Without canvas, we would have had to resort to some serious hackery in order to rotate the balls and manipulate the pool cue.
- We also made massive use of the Audio element for sound effects. In fact, we found out early on that browsers have a ceiling on the number of audio elements you can create (probably related to the number of simultaneous sounds you can play on your soundcard). 32 seems to be a magic number.
- Finally, all of our typography is done with @font-face font embedding (using the ever so awesome .WOFF format). Incidentally, @font-face embedding could not be easier, especially with great tools like typekit and the font-squirrel generator. This isn’t technically an HTML5 feature (I think it’s CSS2) but it kind of feels like one.
HTML5 for Apps and Games
We’ve worked with a lot of UI platforms (WPF, Silverlight, Flash and iOS) and always felt like HTML does a stunning job with its core competency: document layout. But what about HTML for apps? Admittedly apps (and games) feel a little shoehorned in. The stunning success of HTML as an app platform (which, at least by volume, is undeniable) seems to be a little bit in spite of itself (and due to the ingenuity and hacking skillz of a lot of smart developers). It’s sort of amazing that a document layout engine has become a reasonable platform for building games or sophisticated applications.
Well, even in version 5, HTML is still not a complete UI package but I can‘t help but feel like it represents an important and fundamental step in that direction. We’re closer than ever to an HTML that feels like it was intended for apps! While you can make a good case that many important UI constructs are still very rudimentary or missing (e.g. an extensible component model—checkout Quick UI in the meantime, UI-focused layout, data-binding, etc.), HTML5 gives us important building blocks we’ve never had before.
If you think about a modern UI stack, the most fundamental layer in the cake is the rendering and media layer. And that’s where everyone tends to start: Flash started there and so did Silverlight. The first versions of both of those platforms offered little more than rendering and media. If you think about it, even Windows (and likely other OSs) followed that trajectory.
HTML5 gives us our rendering and media stack! We’re still early, but this represents a true shift from “designed for documents” to “designed for applications and games.” Canvas is a surprisingly effective (and fast!) rendering surface (check out this realtime video processing). We also get media integration with the Audio/Media elements and we even get some (less widely implemented) basic 3D constructs with WebGL.
No doubt HTML6 will expand on HTML’s existing (and rudimentary) higher level UI constructs (controls, layout, etc.) and result in something that is even better suited for apps. That will be great. In the meantime, we now have the fundamentals! That’s a great place to build. And it also turns out that a game is a good match to that excitingly new bottom layer!
What’s Next for 008 Ball?
You’ll be happy to know that Agent 008 Ball is alive and well and growing. Our stats are up and we just (quietly) rolled out a new version with some significant bug fixes. We’re also in the process of cleaning up a bunch of the code so we can share it. We’ve already shared a cleaned up version of the Box2D physics library that we used. The next one coming will be our HTML5 sound effects library.
Maybe after that, we’ll add more than one level to the game!
10 Comments
Tweets that mention nerdplusart.com | Creating an HTML5 Game -- Topsy.com / NOV 10 2010
[...] This post was mentioned on Twitter by Robby Ingebretsen, Mike Sprague, Vitor A. Vale, codenux, Kelps Leite de Sousa and others. Kelps Leite de Sousa said: RT @ingebretsen: new blog post: Creating an HTML5 Game (includes a sweet video about agent8 ball): http://j.mp/aRe5yn [...]
Nishant / NOV 10 2010
Thanks for the video, Robby. Always appreciate a behind-the-scenes look. The artboard for Agent 008 Ball is gorgeous. Your post kinda reminds me of the early days of Flash (5/MX) where folks were creating physics engines in seemingly impossible ways because ActionScript wasn’t really there yet. Funny how history keeps repeating itself. :)
David Seruyange / DEC 04 2010
Really like seeing your process on display. Also liked the nod to St. Etienne.
onedayitwillmake / DEC 28 2010
You cleaned up the sadly defunct Box2D JS port – and put it back on github…. wow awesome!
onedayitwillmake / DEC 28 2010
(lol – that is not meant to sound sarcastic btw)
Webfanatix / FEB 17 2011
Brilliant design. You guys really did your homework on this project.
zu / FEB 17 2011
wow! awesome!
Breakall / MAR 11 2011
Great video, thanks for taking the time to share the process.
Dino / MAR 16 2011
Agent 008 Ball is a wonderful concept. I’m new to the web development and design arena being a computer technician by trade. In 1995, I worked with HTML and I wasn’t really impressed by it. Using tables and having to space things with invisible GIF’s, I didn’t see the larger and more creative picture. I missed out on being involved in the growth of HTML (and it’s web standard cousin XHTML), but I am really excited to get involved now. While I looked at the source for Agent 008, I was amazed at how simple but tedious it was to write it; preloading all those images! I hope that part was automated. I was looking for something to tell me how did you make this application (game) and you did. Thank you for that. I’m still in the learning mode phase of my pursuit to add web development to my growing set of IT skills.
Thanks for a great app, a great blog, and sharing it with others.
.net Awards 2011: top 10 online games - My Best Games / AUG 30 2011
[...] .net: What tools and technologies did you use?RI: The game is completely written in JavaScript and almost all of the game rendering is done in a canvas element. we used a port of the Box2D physics library for all of the physics and we used Google's Closure Compiler to keep our JavaScript clean and compact. for more, check out thinkpixellab.com/casestudy/agent-008-ball/ and nerdplusart.com/creating-an-html5-game. [...]