Here's an example:
phy start
make object cube 1,10
position object 1,-30,100,0
phy make rigid body dynamic box 1
phy set rigid body angular velocity 1,80,0,0
make object cube 2,10
position object 2,20,-90,0
phy make rigid body dynamic box 2
make object box 3,300,10,300
position object 3,0,-100,0
phy make rigid body static box 3
color object 3,rgb(128,0,128)
do
`when collision between cube and terrain, apply same forces to other cube
if object collision(1,3) = 1 and rkey = 0
`get object data
linx# = phy get rigid body linear velocity x(1)
liny# = phy get rigid body linear velocity y(1)
linz# = phy get rigid body linear velocity z(1)
angx# = phy get rigid body angular velocity x(1)
angy# = phy get rigid body angular velocity y(1)
angz# = phy get rigid body angular velocity z(1)
posx# = object position x(1)
posy# = object position y(1)
posz# = object position z(1)
rotx# = object angle x(1)
roty# = object angle y(1)
rotz# = object angle z(1)
`apply to new object
phy set rigid body position 2,posx#+50, posy#,posz#
phy set rigid body rotation 2,rotx#, roty#, rotz#
phy set rigid body linear velocity 2,linx#,liny#,linz#
phy set rigid body angular velocity 2,angx#,angy#,angz#
rkey = 1
endif
phy update
sync
loop
Theory is when you know something, but it doesn't work. Practice is when something works, but you don't know why.
Programmers combine theory and practice: Nothing works and they don't know why.