Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.


Results 1 to 2 of 2

Thread: Pushing/Anti-Gravity Wind Effect in AS2

  1. #1

    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.

    //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;
    I would really appreciate it if you helped! Thanks!

  2. #2
    First 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.


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Home About kirupa.com Meet the Moderators Advertise

 Link to Us


Copyright 1999 - 2012