HTML5 canvas implementation of classic bat and ball game