
-----------------------------------
NikG
Mon May 15, 2006 6:57 pm

Ball bouncing effect
-----------------------------------
Something I was just playing with... a ball falling and bouncing off the bottom of the screen.  I tried to simulate friction and gravity.
View.Set ("offscreenonly")

var BallX := 50.0
var BallY := 200.0 %starting ball height
var maxBallY := BallY
var newVelMplr := 0.069 %0.068 to 0.075

var VelX := 2.5
var VelY := 0.0
var Gravity := -0.6 %good values from -0.49 to -0.71
var Friction := -0.09

loop
    BallX += VelX
    BallY += VelY
    if BallY > maxBallY then
        maxBallY := BallY
    end if
    VelY += Gravity
    if round (BallY)  0 then
            VelX += Friction
        end if
    end if

    drawfilloval (round (BallX), round (BallY), 10, 10, green)
    View.Update

    exit when VelX _> I always think of those "hey I wonder how we could do that..." thinks. Then I get worked up and can't sleep (generally I think about these things while lying in bed lol)

-----------------------------------
sylvester-27
Thu May 25, 2006 7:30 am


-----------------------------------
actually the maximum velocity for objects falling to earth is 9.81 m/s.  :D  ya the ball falling thing is pretty good

-----------------------------------
Aziz
Thu May 25, 2006 2:21 pm


-----------------------------------
actually the maximum velocity for objects falling to earth is 9.81 m/s.  :D  ya the ball falling thing is pretty good

You mean acceleration :P Acceleration due to gravity is 9.8m/s^2. Velocity for a falling object at any given time is HEIGHT - 9.8 * TIME (given the object started at rest) Wow, why are we debating physics?

-----------------------------------
NikG
Fri May 26, 2006 11:40 pm


-----------------------------------
I tried adding the Mouse drag code and it works for the most part:View.Set ("offscreenonly")

var x, y, b, b2 : int
var BallInHand := false
var BallInMotion := true

var BallX := 50.0
var BallY := 200.0 %starting ball height
var maxBallY := BallY
var newVelMplr := 0.068 %0.068 to 0.075

var VelX := 2.0
var VelY := 0.0
var Gravity := -0.6 %good values from -0.49 to -0.71
var Friction := -0.11

loop
    Mouse.Where (x, y, b)

    if Mouse.ButtonMoved ("down") and Math.Distance (x, y, BallX, BallY)  maxBallY then
                maxBallY := BallY
            end if
            if round (BallY)  0 then
                    VelY := maxBallY * newVelMplr
                    maxBallY := 0
                    VelX += Friction
                else
                    BallInMotion := false
                end if
            end if
        end if
    end if

    drawline (0, 20, maxx, 20, black)
    drawfilloval (round (BallX), round (BallY), 10, 10, green)
    View.Update
    delay (35)
    drawfilloval (round (BallX), round (BallY), 10, 10, white)
end loop
There are a few problems though... for some reason, the ball seems to jump higher if you drop it from too high, and I still haven't gotten a good feel for friction.

-----------------------------------
_justin_
Mon May 29, 2006 7:35 pm


-----------------------------------
wow man thats pretty awesome real nice work keep it up

-----------------------------------
sylvester-27
Wed May 31, 2006 7:34 am


-----------------------------------
dunno, we just finished the Motion unit of gr 10 science. i can't believe i said maximum velocity. i think like the max v for a human is like 200 km/h.

-----------------------------------
TheOneTrueGod
Wed May 31, 2006 1:25 pm


-----------------------------------
Terminal velocity changes based on the surface area of the object in question.  Therefore, someone with very large surface area (Doesn't need to be 'heavy', just very wide) will have a different terminal velocity than someone with less surface area.  (It is also dependant on density, I believe, and theres probably a few other things I missed out on, but eh.  Thats the basics.)

-----------------------------------
Clayton
Wed May 31, 2006 8:13 pm


-----------------------------------
weight distribution also has to do with terminal velocity, if you have a paper with a stone tied to one side of it, the paper will obviously fall faster and more upright than one without :D
