# 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, 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 equaitions is:

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

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

```
• ... AudioGames . net Forum — Developers room : severestormsteve1 via Audiogames-reflector
• ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
• ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
• ... AudioGames . net Forum — Developers room : severestormsteve1 via Audiogames-reflector
• ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
• ... AudioGames . net Forum — Developers room : severestormsteve1 via Audiogames-reflector
• ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
• ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
• ... AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector
• ... AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector
• ... AudioGames . net Forum — Developers room : severestormsteve1 via Audiogames-reflector