Ported Javascript sprite code from http://dev.opera.com/articles/view/3d-games-with-canvas-and-raycasting-part-2/