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

Basically what I'm trying to do is:

ball.speed is the speed vector so

ball.speed.x is horizontal speed, ball.speed.y is back and forward speed.

ball.speed1 is ball's total speed, all the vector values absolute values added together, velocity in other words.

ball.theta was the calculated angle distance between 0, 0, with a theta of 0, and the ball's speed x and y entered as coordinates. Therefore, if the ball's x speed was 10 and its y speed was 10, its theta would be 45 degrees because 10, 10, is 45 degrees away from 0, 0, with a theta of 0. I can post the angle distance calculation function if you want me to.

ball.v is the ball's coordinates vector.

ball.v.x, ball.v.y is the position of the center of the ball.

ball.radius is the radius of the ball.

ball.weight is the weight of the ball.

block is the block object

block has x, y, strength.

If the ball collides with a block, I use Magurp244's calcul
ation to calculate how hard it hit based on ball.theta and ball.speed1, then multiply that result by ball.weight. weight is a hole number.

Then to deflect it, I would have:

If the ball collided with the block to its left, I would first add the collision angle to the theta, and then invert the theta, to spin it to the right.

If the collision was to the right, I would think I would subtract the collision angle and then invert.

I'm not calling anyone wrong, and I'm not saying this is the right and only right way and I refuse to change it based on anything you guys say. I was just clearing up how I was doing things because I don't feel like I did before.

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