This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-01-13 02:16:47

urhungry
Scratcher
Registered: 2009-07-03
Posts: 1000+

Calculating angels?

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

 

#2 2010-01-13 03:14:46

fanofcena
Scratcher
Registered: 2008-07-03
Posts: 1000+

Re: Calculating angels?

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)


http://i53.tinypic.com/2vxr2c0.png Click whats above u might make a cute planet happy ^_^

Offline

 

#3 2010-01-13 16:16:51

urhungry
Scratcher
Registered: 2009-07-03
Posts: 1000+

Re: Calculating angels?

Thanks! I had no idea if what to do. I'll use this a lot.

Offline

 

#4 2010-01-13 21:24:17

fanofcena
Scratcher
Registered: 2008-07-03
Posts: 1000+

Re: Calculating angels?

smile


http://i53.tinypic.com/2vxr2c0.png Click whats above u might make a cute planet happy ^_^

Offline

 

#5 2010-01-13 21:36:25

greenflash
Scratcher
Registered: 2009-05-27
Posts: 1000+

Re: Calculating angels?

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


http://i48.tinypic.com/2wrkirk.pnghttp://i46.tinypic.com/6r5zk7.pnghttp://i45.tinypic.com/2vtxr1t.png

Offline

 

Board footer