
-----------------------------------
Token
Wed Sep 21, 2005 8:36 pm

Bouncing ball
-----------------------------------
okay, heres my problem, I'm working on a little program that has a ball bouncing. I'm trying to make it realistic so that the ball falls to rest after loosing momentum, take a look at the code, and see if you can find out how to make it eventually stop bouncing. **you can drag the ball higher to drop it from higher.

setscreen ("Graphics:max;max,offscreenonly")

var x, y, acc, gravity : real
var mx, my, mb, rad, dir : int


rad := 10
acc := 0
dir := -1
gravity := 4.9
x := maxx div 2
y := maxy - rad - 500

drawfillbox (0, 0, maxx, 40, black)



loop
    mousewhere (mx, my, mb)


    if mb = 1 and whatdotcolor (mx, my) = red then        %Draging the ball

        loop
            mousewhere (mx, my, mb)
            exit when mb = 0
            x := mx
            y := my
            cls
            drawfillbox (0, 0, maxx, 40, black)
            drawfilloval (round (x), round (y), rad, rad, red)
            View.Update
        end loop
        dir := -1
        acc := 0

    elsif dir = 1 and acc 