HTML and CSS Reference
Shooting the ball
We change the state of the ball from staic to dynamic before applying some force to it.
Forces only affect dynamic bodies.
Once we know any two points in the screen, we can calculate the rotaion angle. This is
done using the geometry formula. The following igure shows the relaionship between
the edges of the triangle and angles between them:
The calculated angle is correct only if it is in the first quadrant. We determine the quadrant
of the mouse cursor by referencing the ball's posiion as the original point. The following
figure shows the four quadrants:
According to math, we need to add addiional degrees to the calculated result if the cursor
is not in the first quadrant. The degrees to be added, depending on the quadrant, are shown
F Quadrant 1: Add 0
F Quadrant 2 and 3: Add 180 (PI)
F Quadrant 4: Add 360 ( PI * 2 )