Then I use an if statement for position followed by... (go is the instance name of the square movie clip)
go._x += velX;
go._y += moveY;
What would be a way to smooth out the animation without using that targetX - go._x technique which slows it down as it nears the target?
Man, this shit is so much fun. Thanks to everyone (especially Steve) who has helped me out!
Here's the full code on the clip responsible for the movie...
gravity, theta, and formVel are all set by the user in the form. t is set in the first frame of my actions layer to be equal to 1. Figured that might be the easiest way to take care of the time interval...
We all should come equiped with the option of negative gravity.
Hey - that makes me think of something. If some yahoo does put in negative values for gravity, y will always be less than what your conditional checks for, and the loop will never stop. Wow. I'm trying to imagine how far my little square actually got before I clicked reset. Wish my monitor was that big!
On a "real" project, you could probably defeat negative gravity using the Absolute Value function - Math.abs() I think it is
[This message has been edited by Steve (edited 09-26-2001).]
Slime - I though of your cannon as soon as Krets started talking about a "poo-cannon"! I *LOVE* that thingie of yours.
Krets has a way to go yet, heh. But a good start!
Krets - where'd you pick up the trig? Moving on an arc still devils me. Didn't pay enough attention the day they talked about theta!
If you do start to do more trig stuff, Flash will trick you a bit. Firstly, it likes things in Radians. Secondly, degrees in positive numbers create counterclockwise rotation. Third, there's that bit about non-cartesian y coordinates.
From: A little lower... lower... ahhhhhh, thats the spot Insane since: Jun 2000
posted 09-26-2001 20:32
Well Steve, my major in college was Secondary Education Chemistry and Physics so I picked up most of it there. It helps that I taught Phys labs in college too so I had some practical experience using projectile motion.
When I student-taught a physics class my last year of college I had my kids create water balloon slingshots. They had to be able to devise a way to accurately aim their balloons at a target. Basically I gave them 3 days to prepare and then I gave them the angle of launch. All they had to do was calculate the distance and tell me where to stand. If they hit me they got extra credit. Only one group hit me and I was standing 100 meters away. They hit me twice. Pretty damned accurate for some surgical tubing and a rubber cup.
I think I can get the canon to follow the mouse, I just need to read up on the techniques. I know that Flash can instantly recognize the mouse position using mouse._x and mouse._y right? Shouldn't be too tough after that. I just need the time!
From: A little lower... lower... ahhhhhh, thats the spot Insane since: Jun 2000
posted 09-26-2001 21:48
Could you hook me up with a URL there Steve? I went there yesterday to try and find them but man, that site is frickin confusing... Don't get me wrong, I love just playing with all the toys but I could never seem to find the tank game...
Oh, btw, I don't think the physics in that thing are correct - the object doesn't follow a perfect parabolic path. The highest point in its path should be midway between the starting and ending points, and it seems to be from the right. That's not true if there's air resistance, however. So if you meant for there to be air resistance, then it works prefectly. =)
The problem could be the fact that you're using "go._y += moveY", judging from the formula you use to calculate moveY, I believe you want a direct assignment there, "go._y = moveY". You're adding distance to distance otherwise. You want to either *assign* distance to distance, or add *velocity* to discance (velocity is calculated by v = v0 + a*t.)
[edit: using the "go._y += velocityY" way instead of the "d = moveY" way may be ever so slightly faster to calculate, although ever so slightly less accurate, also.]
[This message has been edited by Slime (edited 09-26-2001).]
From: A little lower... lower... ahhhhhh, thats the spot Insane since: Jun 2000
posted 09-27-2001 00:23
Slime I think the fact that the puck doesn't stop at the horizon is deceiving you.
s = v(i)t + .5at^2 (Neglecting air resistance)
Actually, that should be change in s, not just s. Thats why I am using go._y += moveY I am calculating the change in distance over the time interval then adding that to the current position.
Damnit, the batteries on my graphing calculator are dead, otherwise I was going to plug in some numbers.....