A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Deceleration

  1. #1
    Senior Member
    Join Date
    Aug 2000
    Posts
    135
    Hi there,

    Ahab, I know you already helped with this, but it doesn't seem to be working. Maybe because of the way my game is set up. Right now, it's set up that so that as the speed gets increased the final size of the birds diving will always be the same.

    Code:
    BirdSpeed = 5;
    Scale = BirdSpeed*.4;
    -------------------------------------------------
    setProperty (Bird, _y, Bird._y+BirdSpeed);
    setProperty (Bird, _xscale, Bird._xscale +Scale);
    setProperty (Bird, _yscale, Bird._yscale +Scale);
    Now, I want to make the birds slow down as they aproach the bottom of the screen. For example:
    The bird starts diving at speed 5 (this will increase as the levels do). By the time the bird is at the bottom of the screen it will have slowed down to 2.

    I want the final speed and final size to always be the same. It is only the intial speed and the intial size that change.

    I'd appreciate any help anyone can give-
    Dave

  2. #2
    Senior Member
    Join Date
    Jun 2000
    Posts
    896
    screen_height=whatever
    speed=finalspeed+(initialspeed-finalspeed)*(screen_height-current_y)/screen_height)

    this will give you speed as a function of y. there is only 1 dynamic variable in that eq, current_y. the maximum speed is at y=0, and minium at y=screen_height.

    this should be a good starting place for you


  3. #3
    Senior Member
    Join Date
    Aug 2000
    Posts
    135

    birds wont be starting at 0

    This is great. Thanks.

    There is one issue though. The birds wont ever be starting at 0. They'll be starting a slightly different spots each time.

    Also, does this function compensate for the gradual scaling of the birds as they reach the bottom? (The the previous scaling equations I had.)

    -Dave
    [Edited by Dafted on 10-24-2000 at 10:04 AM]

  4. #4
    Senior Member
    Join Date
    Jun 2000
    Posts
    896
    hi

    i meant to give you the code as a starting point. if you dont want them to start at y=0 then that is fine, a simple equation alteration will take care of that. what you wanted was a velocity that would be reached at the bottom. making the equation(s) y dependant will work for any velocity. other wise you will need to hard code in decay factors which is a pain.

    also, your message requested speed help, not scaling. i'm sorry that i didnt post anything regarding scaling but that is why.

    do you still need some help? i dont mind.

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center