Dodge, now on a canvas

Whenever I am learning a new language or platform, I seem to end up writing Dodge again. Move a square around, avoid the bad blocks, and see how long you can keep going. This time I tried it with the HTML canvas.

It is an 800-by-600 canvas with a plain JavaScript loop running about twenty times a second. The mouse moves the player, enemies enter from the edges, and rectangle intersection checks handle collisions. Staying alive makes the square grow; collecting a green block shrinks it and adds points. The previous score and high score stay around in memory while the page is open.

I actually showed a version of this to my interviewer when I applied to the Internet Explorer team. I cannot say whether it was what got me the internship, but it was nice to have something I could actually show rather than just talk about. Not bad for a game made mostly out of rectangles.

Play Canvas Dodge