Updated version that allows you to hold left mouse button to change the ycoord of a block. then dropping it applies gravity.
Sync On
Sync Rate 60
Autocam Off
Make Matrix 1,100,100,10,10
position camera 0,20,0
`Gravity
gravity# = 9.8
elapsedtime = 0
startTime = timer()
GLOBAL SetupOnce = 0
IntitVelocity# = .1
Type Object
ID as Integer
Mass# as Float
StartXCoord# as Float
StartYCoord# as Float
StartZCoord# as Float
XCoord# as Float
YCoord# as Float
ZCoord# as Float
Velocity# as Float
EndType
Dim objects(100) as Object
objects(1).ID = 1
objects(1).Mass# = 5.0
objects(1).StartXCoord# = rnd(100)
objects(1).StartYCoord# = 0
objects(1).StartZCoord# = rnd(100)
objects(1).Velocity# = IntitVelocity#
objects(2).ID = 2
objects(2).Mass# = 10.0
objects(2).StartXCoord# = rnd(100)
objects(2).StartYCoord# = 0
objects(2).StartZCoord# = rnd(100)
objects(2).Velocity# = IntitVelocity#
For x = 1 to 100
If objects(x).ID > 0
Make Object Cube x,objects(x).Mass#
Position Object objects(x).ID,objects(x).StartXCoord# ,objects(x).StartYCoord#,objects(x).StartZCoord#
EndIf
Next x
Do
rotate camera camera angle x()+mousemovey(),camera angle y()+mousemovex(),0
position mouse screen width()/2,screen height()/2
If SetupOnce = 0
startTime# = timer()
SetupOnce = 1
EndIf
elapsedtime# = (timer() - startTime#)/1000.0
object = pick object( screen width()/2,screen height()/2, 1, 10000 )
if mouseclick() = 1 and object > 0
SetupOnce = 0
objectReal = objects(object).ID
objects(object).Velocity# = 0
objects(object).YCoord# = camera position y() + get pick vector y()
position object objectReal,objects(object).XCoord#,objects(object).YCoord#,objects(object).ZCoord#
else
For x = 1 to 100
If objects(x).ID > 0
objects(x).XCoord# = object position x(objects(x).ID)
objects(x).YCoord# = object position y(objects(x).ID)
objects(x).ZCoord# = object position z(objects(x).ID)
if (objects(x).YCoord# > 0)
objects(x).YCoord# = objects(x).YCoord# - objects(x).Velocity#
`V = Vo + at
objects(x).Velocity# = IntitVelocity# + gravity# * elapsedtime#
`Terminal Velocity
if objects(x).Velocity# >= gravity#
objects(x).Velocity# = gravity#
EndIf
position object objects(x).ID, objects(x).XCoord#,objects(x).YCoord#, objects(x).ZCoord#
EndIf
`If object hits 0
if (objects(x).YCoord# <= 0)
objects(x).YCoord# = 0
position object objects(x).ID, objects(x).XCoord#,0,objects(x).ZCoord#
EndIf
EndIf
Next x
EndIf
text 0,0,"Smaller Object's Final Velocity: " + str$(objects(1).Velocity#)
text 0,15,"Larger Object's Final Velocity: " + str$(objects(2).Velocity#)
Sync
Loop