O'Reilly logo

Learning HTML5 Game Programming: Build Online Games with Canvas, SVG, and WebGL by James L. Williams

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

5. Creating Games with the Canvas Tag

The Canvas (that is, the canvas tag) is what many think about when HTML5 is mentioned. Instead of creating a bunch of div elements with contained images with CSS to simulate movement and game play, you can use canvas to provide a surface to draw objects on the screen. Neither method is easier or harder, but each has different considerations. The Canvas has some built-in translation, rotation, scaling, and clipping, whereas with divs you have to handle transformations yourself. However, one advantage that games using div and CSS have over the Canvas is that older browsers, such as Internet Explorer 6, are supported. Hopefully, as more browsers become HTML5 compliant, this will become less of an issue.

Getting ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required