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

Bleh, I think this is considered more 2D Physics actually, I haven't played with this stuff all that much so appologies if its not that helpful. You could actually do it on collision instead of calculating a line, I dug up a Pong example in python [link] that likely has collision/deflection code you could use, although i'm not sure what language your using.

The general idea is that velocity is the measure of power with the angle being the percentage of that power being transfered to the surface, or damage in other words. So if you drop a ball straight down at a 90 degree vertical angle relative to a flat surface that would impart 100% of its power/velocity to that surface, if you throw the ball at a 45 degree angle towards the ground it would be 50% power, 22.5 degree angle 25% power, etc. So you'd calculate the balls angle relative to the surface and convert it into a percentage, for example:

``32 degree angle / 100 = 0.32 * 90 total degrees = 28.8 percent``

Then you use that to calculate the percentage of velocity power to damage the surface:

``(28.8 angle/100) * 84 velocity = 24.192 power``

This gives you the remaining power, or damage, that would be applied to the surface, in this case 24.192 damage with a total velocity of 84 at a 32 degree angle of impact.

```

_______________________________________________
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