# Re: How can I calculate damage based on speed and direction?

Hmm, I think you'd have to apply trigonometry to calculate the angle, then add/subtract from velocity to simulate deflection. So, taking the direction and velocity i'd calculate a line to find a point of collision, then use the line to calculate the Adjacent and Opposite angles, depending on whether the ball is moving vertically or horrizontally. Then, depending on the degree of the angle i'd add/subtract the velocity to increase or decrease the damage output.

The Longest Side is the the Hypotenuse, the equation to find it is:

`Tangent: tan(0) = Opposite divided by Adjacent`

The Adjacent angle is parrallel to the Hypotenuse, which is best used if the ball is moving up or down, the equation for finding it is:

`Sine: sin(0) = Opposite divided by Hypotenuse`

The Opposite angle moves in the opposite direction to the adjacent angle, its best used
for when the ball is moving left or right, its equaitions is:

`Cosine: cos(0) = Adjacent divided by Hypotenuse`

## Advertising

_______________________________________________ Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector