August 10, 2009

HTML 5 Canvas

I was almost giddy when I discovered the canvas tag to be included in HTML 5. With this javascript joins the ranks of C, JAVA and VB in the fact that I can quickly and easily draw straight to the window with a few basic APIs. So to have a little fun and to keep my javascript knowledge fresh, I sat down over the last few days and read up on the canvas APIs and played around a little.

(NOTE: IE does not work with canvas by default, use another newer browser!)

First off I started with the basic balls bouncing around program that I did in every other language that can draw. You can check it out here and see the code here.

I had to do a little research on classes in javascript, and while not exactly perfect, they do work as expected. After getting the bouncing shape test working I moved on to make a simple platform game. The hard thing with javascript is that it is slower and far more processor hungry then even java, so I had to be somewhat careful of sloppy waste, however I did not put too much effort into it as this was nothing more then a way to try out the canvas with javascript. You can see the result here and the code here.

All in all I am excited to see javascript starting to show signs of maturing into a really powerful and useful scripting language.

If interested, you can also read more on the canvas tag here.

No comments: