I'm making a game where tanks shoot fruit at each other, and I need to know how to calcuate the angle of firing and the accereleration and deceleration and arch of the curve and all that. Is it teigonomitry? Thanks for the help!
Offline
well not actually trigonometry its called slope in mathematics
what u need is to do for a straight line.
angle = (atan( y2 - y1/x2 - x1)+90) but beware as if both are on same x this will return 0 value
so its better to make an if statement to do it another way if x2 - x1.
Use the above its a top viewed game
now if u consider real projectile motion the motion of particle =
on x axis = firing vel(cos(angle)) * time;
on y axis = firing vel(sin(angle))*time - 1/2*g*t*t; where g is ur value of gravity using this u can get the resultant angle better if its sideview.
then we get x2 - x1 = vel cos(angle)*t
now y2-y1 = vel sin (angle)*t - 1/2 g*t*t;
confusing now to get result u need to do some maths to find the value of Angle
lemme do it easy for u
if they lie on same hieght the height for the angle desired is :
angle = asin ((x2- x1)*g)/4*u*u;
but for different hieght the formula is quite tricky actually it has more variables then equations. Is this one ok
Last edited by fanofcena (2010-01-13 03:27:45)
Offline
I'm not sure if this uses the same method, but I hope it helps:
http://scratch.mit.edu/projects/Paddle2SeeFixIt/838267
It's a great angle calculator
Offline