Topic: Wheee! Pages that link to <a href="https://ozoneasylum.com/backlink?for=11227" title="Pages that link to Topic: Wheee!" rel="nofollow" >Topic: Wheee!\

 
Author Thread
kretsminky
Maniac (V) Inmate

From: A little lower... lower... ahhhhhh, thats the spot
Insane since: Jun 2000

IP logged posted posted 09-26-2001 06:35 Edit Quote

Finally got this tiny little project "basically" workin as it should...
http://www.krets.net/misc/freakmebaby.html

Any suggestions on how to make the motion more realistic and no so choppy....

Basically right now the X and Y components of the velocity are parsed from the user input (vel) and angle (angl) and then calculated with....

velY = Math.sin(angl)*vel;
velX = Math.cos(angl)*vel;
moveY = -velY*t + .5*a*t*t;

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...

code:
a = parseInt(gravity);
crappyangle = parseInt(theta);
angl = (Math.PI*crappyangle)/180;
vel = parseInt(formVel);
velY = Math.sin(angl)*vel;
velX = Math.cos(angl)*vel;
moveY = -velY*t + .5*a*t*t;

if (go._y < 485) {
go._x += velX;
go._y += moveY;
t++;
} else {
stop();
}







[This message has been edited by kretsminky (edited 09-26-2001).]

GRUMBLE
Paranoid (IV) Mad Scientist

From: Omicron Persei 8
Insane since: Oct 2000

IP logged posted posted 09-26-2001 12:41 Edit Quote

good work krets!
how many fps are you using? (hope that's not the reason)

kretsminky
Maniac (V) Inmate

From: A little lower... lower... ahhhhhh, thats the spot
Insane since: Jun 2000

IP logged posted posted 09-26-2001 13:48 Edit Quote

Sheeeeeeeesh.

OK, yeah, the FPS was part of it. Somehow I had adjusted the FPS down to 5 and didn't notice. Way to go Matt, jeebus.

But its still a bit choppy, how could I improve the motion even more? Any suggestions?

Steve
Maniac (V) Inmate

From: Boston, MA, USA
Insane since: Apr 2000

IP logged posted posted 09-26-2001 18:39 Edit Quote

I like negative values for gravity!

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
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

IP logged posted posted 09-26-2001 19:38 Edit Quote

http://www.karl.nu:4080/slime/slimelaunch/index.html

Copier =)

kretsminky
Maniac (V) Inmate

From: A little lower... lower... ahhhhhh, thats the spot
Insane since: Jun 2000

IP logged posted posted 09-26-2001 19:49 Edit Quote

he he

Ahh, but with mine you can assign negative values.

One of these days I want to work on a canon that will just follow the mouse and then fire when you click.

"One of these days...."

Now I sound like twitch. he he

(I can safely post that because he never comes around these parts.)

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

IP logged posted posted 09-26-2001 20:19 Edit Quote

Krets, if you figure out how to respond to mouse movement and clicks, it's not a huge step from there. I can help with the math if need be. =)

Steve
Maniac (V) Inmate

From: Boston, MA, USA
Insane since: Apr 2000

IP logged posted posted 09-26-2001 20:22 Edit Quote

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.

So much to know .......

kretsminky
Maniac (V) Inmate

From: A little lower... lower... ahhhhhh, thats the spot
Insane since: Jun 2000

IP logged posted posted 09-26-2001 20:32 Edit Quote

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!



Steve
Maniac (V) Inmate

From: Boston, MA, USA
Insane since: Apr 2000

IP logged posted posted 09-26-2001 21:45 Edit Quote

check out the praystation tank game demos

you don't need your cannon to physically move the way Josh has his tank move. But turret rotation toward the mouse and projectile launch might help.

Hey - if you got this thing networked into a MUDD, we could all take a "shot" at a virtual dousing of Krets with his cannon!

Heee heeee

kretsminky
Maniac (V) Inmate

From: A little lower... lower... ahhhhhh, thats the spot
Insane since: Jun 2000

IP logged posted posted 09-26-2001 21:48 Edit Quote

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...

Fig
Paranoid (IV) Mad Scientist

From: Houston, TX, USA
Insane since: Apr 2000

IP logged posted posted 09-26-2001 21:58 Edit Quote

krets, the site just changed and I have no idea where it is now

chris


KAIROSinteractive

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

IP logged posted posted 09-26-2001 22:48 Edit Quote

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).]

kretsminky
Maniac (V) Inmate

From: A little lower... lower... ahhhhhh, thats the spot
Insane since: Jun 2000

IP logged posted posted 09-27-2001 00:23 Edit Quote

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.....



Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu