Adventures in JavaScript Canvas

Written on January 19, 2011 by Kev

I’ve been reading a lot about HTML5 recently and it looks like the browser could soon become the dominant application platform. So, I thought I’d have a look at the new canvas element and delve into some JavaScript.

To get me started I’ve decided to write a (very) simple version of an old classic zx Spectrum  game: Jumping Jack.

At the time of writing this only works in browsers that support the new canvas html element. So yay for Firefox and boo to Internet Explorer.

Click the thumbnail below to run the game. You can the right click or something to view the code.

An experiment in html5 canvas

Click to launch the… erm, ‘game’

If you’re going to use my code as a learning reference then you should note that I’m not a JavaScript programmer and, even then I cut a few corners to speed things up. This simple game is the result of an afternoons tinkering, so don’t expect much!

While the canvas element looks great for simple 2d drawing, the html5 feature that really excites me is WebGL. When its finally available it should be a game changer…