Another code snippet,throwing a rope.
`%ProjectTitle%
`======================
`P.Parkinson
`======================
`Main Source File
sync on
sync rate 60
autocam off
color backdrop 0, 0
set text font "Arial"
set text size 12
set text transparent
position camera 10,80,-80
point camera 0,0,0
position light 0,200,1000,200
set light range 0,10000
`load effect "rainbow.fx",1,0
phy start
make object box 1,2000,1,2000
set shadow shading on 1,-1,1000,1
phy make rigid body static box 1
`*******main loop********
first_red_shot=100
red_shot=first_red_shot
max_red_shot=500
first_green_shot=600
green_shot=first_green_shot
max_green_shot=1000
count=0
do
if spacekey() and count>1
if object exist(red_shot)
phy delete rigid body red_shot
delete object red_shot
if phy get joint exist(red_shot)
phy delete joint red_shot
endif
endif
make object sphere red_shot,1
`set object effect red_shot,1
set shadow shading on red_shot,-1,1000,1
color object red_shot,rgb(255,0,0)
position object red_shot,camera position x(),camera position y(),camera position z()
set object to camera orientation red_shot
move object left red_shot,5
yang#=(rnd(8.0)-4.0)
xang#=(rnd(8.0)-4.0)
yrotate object red_shot,object angle y(red_shot)+yang#
xrotate object red_shot,object angle x(red_shot)+xang#
phy make rigid body dynamic sphere red_shot
phy add rigid body local force red_shot,0,0,200,0,0,1,1
if red_shot=first_red_shot
if object exist(max_red_shot)
phy make fixed joint red_shot,shot,max_red_shot
endif
endif
if red_shot>first_red_shot
if object exist(red_shot-1)
phy make fixed joint red_shot,red_shot,red_shot-1
endif
endif
scale object red_shot,300,300,300
inc red_shot
if red_shot>max_red_shot then red_shot=first_red_shot
if object exist(green_shot)
phy delete rigid body green_shot
delete object green_shot
if phy get joint exist(green_shot)
phy delete joint green_shot
endif
endif
make object sphere green_shot,1
`set object effect green_shot,1
set shadow shading on green_shot,-1,1000,1
color object green_shot,rgb(0,255,0)
position object green_shot,camera position x(),camera position y(),camera position z()
set object to camera orientation green_shot
move object right green_shot,5
yang#=(rnd(8.0)-4.0)
xang#=(rnd(8.0)-4.0)
yrotate object green_shot,object angle y(green_shot)+yang#
xrotate object green_shot,object angle x(green_shot)+xang#
phy make rigid body dynamic sphere green_shot
phy add rigid body local force green_shot,0,0,200,0,0,1,1
if green_shot=first_green_shot
if object exist(max_green_shot)
phy make fixed joint green_shot,shot,max_green_shot
endif
endif
if green_shot>first_green_shot
if object exist(green_shot-1)
phy make fixed joint green_shot,green_shot,green_shot-1
endif
endif
scale object green_shot,300,300,300
inc green_shot
if green_shot>max_green_shot then green_shot=first_green_shot
count=0
endif
inc count
mousecontrol(0.5)
phy update
sync
loop
`*******Functions********
function MouseControl(Speed as float)
xrotate camera camera angle x()+mousemovey()
yrotate camera camera angle y()+mousemovex()
if mouseclick()=1 then move camera Speed
if mouseclick()=2 then move camera (0-Speed)
r=mousemovex()
r=mousemovey()
endfunction