Results 1 to 2 of 2
-
February 13th, 2011, 08:54 PM #11Registered User
posts
Pushing/Anti-Gravity Wind Effect in AS2
Alright guys, so I'm making a game. I want there to be a part where an air vent is pushing against the ball your controlling with your mouse. If you don't get it, check out the swf file from megaswf.com. Trust me, it's safe. No download needed. http://megaswf.com/serve/1008636
As you can see, I've got the idea. That's what I want, the wind pushing the ball and you have to force yourself to push it forward with your arrow/mouse.
The only thing is there's no variation.
I want as you get closer to the right side, the wind gets stronger, and the farther you get from the right side, the calmer the wind gets. Here's some basic snipets of the code I used for the wind to react with the ball. This is not the entire code used in the swf.
I would really appreciate it if you helped! Thanks!Code://Here's the strength of the gravity. gravity = 0.40; ball.onEnterFrame = function() { //there was some more code here that didn't really have anything to do with the wind. xspeed -= gravity; }
-
February 14th, 2011, 04:05 PM #216Registered User
postsFirst off, to give the wind some variation, either try producing a random number for it's strength, or a random delta strength (A small random value you add to the current strength, so the change in strength isn't so sudden).
Another idea is to have it set on a tween (get the sine of the current frame * Math.PI / 180, which would I guess sort of be a fan pushing wind in gusts (not realistically, but hey, it's a game).
I guess just have fun with the gravity variable in real time!
As for the distance thing, just do what you did for the ball pushing, and have the wind strength be something like 1 / distance^2 * gravity (gravity in this case should be huge). That's basically the gravity equation too, except in this case it's pushing the ball away from it's origin.
P.

Reply With Quote


Bookmarks