HTML and CSS Reference
Ater we get the angle, we need the value of the power. The power is based on the ime
duraion of the mouse buton being pressed.
The less amount of ime the mouse buton is being pressed, the less power is applied to the
ball. The longer the mouse buton is pressed, the more power is applied. You may ind that
the power will be hard to control if we use a linear scale. It is very difficult to find the right
iming. Either the power is too litle to be noiceable or too much that the ball lies directly
out of the screen. The duraion is too sensiive.
We use the logarithm to solve this problem. The logarithm makes the shooing power much
smoother. Imagine when we click on the mouse. It is not very different if we keep it pressed
for 500 milliseconds or 1 second. But the value indeed has doubled. That's why the iming is
difficult. The power of force is determined in the millisecond scale. Now with the logarithm,
the value is determined by the exponenial of the duraion. 100 milliseconds may mean
that the value is 1 and 1 second may mean that the value is 2 . It is sill more powerful when
kept pressed for longer. But the value diference is not that sensiive anymore. The following
igure shows how the logarithm decreases the sensiivity:
After we have the angle and power, we decompose the vector into x-axis and y-axis vectors
using a geometry formula. This is the impulse force that we apply to the ball.