An example of how to implement collision detection in the HTML5's canvas.