I had ago at changing it to use the while command system and it now can show two boxes at a time?
have a look. might be me noyt understanding the code.
phy start
autocam off
sync on
sync rate 60
color backdrop 0
position camera 0, 20, -70
` create some objects
make object cube 11, 5
position object 11, -5, 0, 0
Rotate Object 11,rnd(90),rnd(90),rnd(90)
phy make rigid body static mesh 11
make object cube 12, 5
position object 12, -15, 0, 0
Rotate Object 12,rnd(90),rnd(90),rnd(90)
phy make rigid body static mesh 12
make object cube 13, 5
position object 13, 15, 0, 0
Rotate Object 13,rnd(90),rnd(90),rnd(90)
phy make rigid body static mesh 13
make object cube 1, 5
position object 1, 0, -10, 0
Rotate Object 1,rnd(90),rnd(90),rnd(90)
phy make rigid body static box 1
make object cube 2, 5
position object 2, -20, -10, 0
Rotate Object 2,rnd(90),rnd(90),rnd(90)
phy make rigid body static box 2
make object cube 3, 5
position object 3, 20, -10, 0
Rotate Object 3,rnd(90),rnd(90),rnd(90)
phy make rigid body static box 3
make object cube 4, 5
position object 4, 0, 20, 0
make object box 5, 1, 15, 1
position object 5, 0, 15, 0
texture object 4,1
texture object 5,1
` main program loop
do
` display information
` set all objects to black
for i = 1 to 3
color object i, 0
next i
for i = 11 to 13
color object i, 0
next i
` get the position of object 4
x# = object position x ( 4 )
y# = object position y ( 4 )
z# = object position z ( 4 )
value = phy ray cast all shapes ( x#, y#, z#, 0, -1, 0 )
while phy get ray cast hit( )<>0
x# = object position x ( 4 )
y# = object position y ( 4 )
z# = object position z ( 4 )
value = phy ray cast all shapes ( x#, y#, z#, 0, -1, 0 )
` if the ray hit something then colour that object blue
` if phy get ray cast hit( )= 1
color object phy get ray cast object ( ), rgb ( 0, 0, 255 )
text 0,80,"object: " + str$(phy get ray cast object() )
text 0,100,"Dist: " + str$(phy get ray cast distance() )
text 0,120,"normal x: " + str$(phy get ray cast hit normal x())
text 0,140,"normal y: " + str$(phy get ray cast hit normal y())
text 0,160,"normal z: " + str$(phy get ray cast hit normal z())
text 0,180,"point x: " + str$(phy get ray cast hit point x())
text 0,200,"point y: " + str$(phy get ray cast hit point y())
text 0,220,"point z: " + str$(phy get ray cast hit point z())
`move the ray cast left
if leftkey ( )
move object left 4, 0.4
move object left 5, 0.4
endif
` mvoe the ray cast right
if rightkey ( )
move object right 4, 0.4
move object right 5, 0.4
endif
` update the simulation and screen
phy update
if phy get ray cast hit( )=0 :exit
endif
sync
endwhile
` endif
`move the ray cast left
if leftkey ( )
move object left 4, 0.4
move object left 5, 0.4
endif
` mvoe the ray cast right
if rightkey ( )
move object right 4, 0.4
move object right 5, 0.4
endif
` update the simulation and screen
phy update
sync
loop
Dark Physics makes any hot drink go cold.