another update this one looks a bit more like it.
Rem Project: phy_pennyfalls1
Rem Created: 11/06/2008 18:57:42
Rem ***** Main Source File ****
sync on
sync rate 60
set text size 32
print "1"
get image 1,0,0,text width("1"),text height("1"),1
cls
print "2"
get image 2,0,0,text width("2"),text height("2"),1
cls
print "3"
get image 3,0,0,text width("3"),text height("3"),1
cls
set text size 12
autocam off
RANDOMIZE timer()
`phy enable debug
phy start
position camera 0,0,2,-15
`phy set max angular velocity 0.0
phy set skin width 0.006
`phy set bounce threshold -9.0
rem materials
coin_mass#=29.0
nbounce=1
phy make material nbounce, "no bounce"
phy set material restitution nbounce, 0.5
phy build material nbounce
hardwood=2
phy make material hardwood,"hardwood"
phy set material static friction hardwood,0.4
phy set material dynamic friction hardwood,0.4
phy set material restitution hardwood,0.2
phy set material friction combine hardwood,3
phy set material restitution combine hardwood,3
phy build material hardwood
glass=3
phy make material glass,"glass"
phy set material static friction glass,0.1
phy set material dynamic friction glass,0.1
phy set material restitution glass,0.25
phy build material glass
metal=4
phy make material metal,"metal"
phy set material static friction metal,0.8
`phy set material dynamic friction metal,0.5
phy set material restitution metal,0.25
phy set material dynamic friction v metal, 0.5
phy set material friction combine metal,1
phy set material restitution combine metal,1
phy build material metal
rem base
make object box 1,100,1,100
position object 1,0,-1.8,0
color object 1,RGB(128,64,64)
phy make rigid body static box 1
rem coin
load object "coin2.x",100
hide object 100
`phy make rigid body dynamic mesh 100,"coin22.x"
`phy load rigid body dynamic mesh 100,"coin22.x"
rem in out box
make object box 2,10,1.1,10
rotate object 2,0,180,0
color object 2,RGB(0,128,255)
phy make rigid body dynamic box 2,hardwood
phy set rigid body kinematic 2,1
rem bottom base
make object box 3,10,.6,10
position object 3,0,-.7,-1.0
rotate object 3,.9,180,0
color object 3,rgb(255,255,0)
phy make rigid body static box 3,hardwood
rem left side wall
make object box 4,.5,15,5
position object 4,-5,0,-2.5
phy make rigid body static box 4
rem right side wall
make object box 5,.5,15,5
position object 5,5,0,-2.5
phy make rigid body static box 5
rem back wall
make object box 6,10,11,1.6
position object 6,0,6,1.0
phy make rigid body static box 6,hardwood
phy set rigid body ccd 6, 5
rem front glass wall
make object box 7,10,9,.37
position object 7,0,6.10,-.1
ghost object on 7,1
phy make rigid body static box 7,glass
phy set rigid body ccd 7, 5
rem back side stopper
make object box 8,.5,5,5
position object 8,-5,10,-1.0
phy make rigid body static box 8
make object box 9,.5,5,5
position object 9,5,10,-1.0
phy make rigid body static box 9
rem lid
make object box 10,10,1,3
position object 10,0,11,0
phy make rigid body static box 10,hardwood
pin=20
setpin=20
rem make a pins
rem top row
`make object cube pin,1
make object cylinder pin,1
position object pin,0,7,0
scale object pin,8,100,8
rotate object pin,90,0,22.5*7
`rotate object pin,45,0,22.5*7
`fix object pivot 8
phy make rigid body dynamic box pin
phy set rigid body kinematic pin,1
inc pin,1
clone object pin,setpin,1
position object pin,1.5,7,0
`rotate object pin,90,0,22.5*7
phy make rigid body dynamic box pin
phy set rigid body kinematic pin,1
inc pin,1
clone object pin,setpin
position object pin,-1.5,7,0
phy make rigid body dynamic box pin
phy set rigid body kinematic pin,1
inc pin,1
clone object pin,setpin
position object pin,-3.0,7,0
phy make rigid body dynamic box pin
phy set rigid body kinematic pin,1
inc pin,1
clone object pin,setpin
position object pin,3.0,7,0
phy make rigid body dynamic box pin
phy set rigid body kinematic pin,1
inc pin,1
clone object pin,setpin
position object pin,-4.5,7,0
phy make rigid body dynamic box pin
phy set rigid body kinematic pin,1
inc pin,1
clone object pin,setpin
position object pin,4.5,7,0
phy make rigid body dynamic box pin
phy set rigid body kinematic pin,1
rem one row down
inc pin,1
clone object pin,setpin
position object pin,-.75,5.5,0
phy make rigid body dynamic box pin
phy set rigid body kinematic pin,1
inc pin,1
clone object pin,setpin
position object pin,.75,5.5,0
phy make rigid body dynamic box pin
phy set rigid body kinematic pin,1
inc pin,1
clone object pin,setpin
position object pin,2.5,5.5,0
phy make rigid body dynamic box pin
phy set rigid body kinematic pin,1
inc pin,1
clone object pin,setpin
position object pin,-2.5,5.5,0
phy make rigid body dynamic box pin
phy set rigid body kinematic pin,1
inc pin,1
clone object pin,setpin
position object pin,-4.0,5.5,0
phy make rigid body dynamic box pin
phy set rigid body kinematic pin,1
inc pin,1
clone object pin,setpin
position object pin,4.0,5.5,0
phy make rigid body dynamic box pin
phy set rigid body kinematic pin,1
rem two rows down
inc pin,1
clone object pin,setpin
position object pin,0,4,0
phy make rigid body dynamic box pin
phy set rigid body kinematic pin,1
inc pin,1
clone object pin,setpin
position object pin,1.5,4,0
phy make rigid body dynamic box pin
phy set rigid body kinematic pin,1
inc pin,1
clone object pin,setpin
position object pin,-1.5,4,0
phy make rigid body dynamic box pin
phy set rigid body kinematic pin,1
inc pin,1
clone object pin,setpin
position object pin,-3.0,4,0
phy make rigid body dynamic box pin
phy set rigid body kinematic pin,1
inc pin,1
clone object pin,setpin
position object pin,3,4,0
phy make rigid body dynamic box pin
phy set rigid body kinematic pin,1
inc pin,1
clone object pin,setpin
position object pin,4.5,4,0
phy make rigid body dynamic box pin
phy set rigid body kinematic pin,1
inc pin,1
clone object pin,setpin
position object pin,-4.5,4,0
phy make rigid body dynamic box pin
phy set rigid body kinematic pin,1
rem bottom row of pins
inc pin,1
clone object pin,setpin
position object pin,-.75,2.5,0
phy make rigid body dynamic box pin
phy set rigid body kinematic pin,1
inc pin,1
clone object pin,setpin
position object pin,.75,2.5,0
phy make rigid body dynamic box pin
phy set rigid body kinematic pin,1
inc pin,1
clone object pin,setpin
position object pin,2.5,2.5,0
phy make rigid body dynamic box pin
phy set rigid body kinematic pin,1
inc pin,1
clone object pin,setpin
position object pin,-2.5,2.5,0
phy make rigid body dynamic box pin
phy set rigid body kinematic pin,1
inc pin,1
clone object pin,setpin
position object pin,-4.0,2.5,0
phy make rigid body dynamic box pin
phy set rigid body kinematic pin,1
inc pin,1
clone object pin,setpin
position object pin,4.0,2.5,0
phy make rigid body dynamic box pin
phy set rigid body kinematic pin,1
rem coin droppers
make object cube 50,1.2
texture object 50,1
position object 50,-3.0,10,0
make object cube 51,1.2
texture object 51,2
position object 51,0.0,10,0
make object cube 52,1.2
texture object 52,3
position object 52,3.0,10,0
rem 5.3
rem -0.05
id=101
do
text 0,0,str$(id-101)
rem platform in
if z#<3.3 and done=0
inc z#,.01
hold=timer()
else
if z#>3.3 and timer()>hold+1000
done=1
endif
endif
rem out
if z#>2.0 and done
dec z#,.01
hold=timer()
else
if z#<2.0 and timer()>hold+1000
done=0
endif
endif
rem pick a box and make a coin and drop it.
gosub _drag_object
rem move the platform
phy set rigid body kinematic position 2, 0, 0, z#
`phy set rigid body kinematic rotation 8,0.0,0.0,wrapvalue((360)+r#)
for j = setpin to pin
d=rnd(1)
if d=0
phy set rigid body kinematic rotation j,90.0,0.0,wrapvalue(390)-r#
else
phy set rigid body kinematic rotation j,90.0,0.0,wrapvalue(390)+r#
endif
next j
`for j = setpin+7 to pin+7 step 7
`phy set rigid body kinematic rotation j,90.0,0.0,wrapvalue(390)+r#
`next j
inc r#,.1
if r#>1000 then r#=0
rem guess
control camera using arrowkeys 0,.1,.1
phy update
sync
loop
_drag_object:
if mouseclick()=0
pickmode=0 : cursorobj=0 :click=0
rem return to dark state.
for k=50 to 52
set object specular k, rgb ( rnd ( 255 ), rnd ( 255 ), rnd ( 255 ) )
set object specular power k, 0
set object ambient k,1
next k
endif
slv#=60000.0
mclick=mouseclick()
if mclick>0
if pickmode=0
cursorobj=pick object(mousex(),mousey(),50,52)
if cursorobj=50
set object specular 50, rgb ( rnd ( 255 ), rnd ( 255 ), rnd ( 255 ) )
set object specular power 50, 255
set object ambient 50,0
endif
if cursorobj=51
set object specular 51, rgb ( rnd ( 255 ), rnd ( 255 ), rnd ( 255 ) )
set object specular power 51, 255
set object ambient 51,0
endif
if cursorobj=52
set object specular 52, rgb ( rnd ( 255 ), rnd ( 255 ), rnd ( 255 ) )
set object specular power 52, 255
set object ambient 52,0
endif
if cursorobj>0
pickmode=mclick
pickdistance#=get pick distance()
pickfromx#=get pick vector x()
pickfromy#=get pick vector y()
pickfromz#=get pick vector z()
if pickmode=1
objx#=object position x(cursorobj)
objy#=object position y(cursorobj)
objz#=object position z(cursorobj)
else
objx#=object angle x(cursorobj)
objy#=object angle y(cursorobj)
objz#=object angle z(cursorobj)
pickdiffx#=mousemovey() : pickdiffx#=0
pickdiffy#=mousemovex() : pickdiffy#=0
endif
else
highlightobj=0
endif
endif
if pickmode>0
if pickmode=1
pick screen mousex(),mousey(),pickdistance#
picktox#=get pick vector x()
picktoy#=get pick vector y()
picktoz#=get pick vector z()
pickdiffx#=picktox#-pickfromx#
pickdiffy#=picktoy#-pickfromy#
pickdiffz#=picktoz#-pickfromz#
grid=0
if grid=1
pickdiffx#=int(pickdiffx#/5)*5
pickdiffy#=int(pickdiffy#/5)*5
pickdiffz#=int(pickdiffz#/5)*5
endif
if cursorobj=50 and click<>1 and timer()>time+1500
click=1
clone object id,100
t=rnd(2)
if t=0
position object id,-2.9.0,9.8,0
endif
if t=1
position object id,-3.0,9.8,0
endif
if t=2
position object id,-3.1,9.8,0
endif
color object id,RGB(0,0,255)
phy make rigid body dynamic box id,metal
phy set rigid body mass id ,coin_mass#
phy set rigid body sleep linear velocity ID, slv#
phy set rigid body sleep angular velocity ID, slv#
phy set rigid body linear damping ID, .5
phy set rigid body ccd id, 1
inc id
time=timer()
endif
if cursorobj=51 and click<>1 and timer()>time1+1500
click=1
clone object id,100
t2=rnd(2)
if t=0
position object id,0.1,9.8,0
endif
if t=1
position object id,0,9.8,0
endif
if t=2
position object id,-0.1,9.8,0
endif
color object id,RGB(0,255,0)
phy make rigid body dynamic box id,metal
phy set rigid body mass id ,coin_mass#
phy set rigid body linear damping ID, .5
phy set rigid body sleep linear velocity ID, slv#
phy set rigid body sleep angular velocity ID, slv#
phy set rigid body ccd id, 1
inc id
time1=timer()
endif
if cursorobj=52 and click<>1 and timer()>time2+1500
click=1
clone object id,100
t3=rnd(2)
if t=0
position object id,3.1,9.8,0
endif
if t=1
position object id,3.0,9.8,0
endif
if t=2
position object id,2.9,9.8,0
endif
color object id,RGB(255,0,0)
phy make rigid body dynamic box id,metal
phy set rigid body mass id ,coin_mass#
phy set rigid body linear damping ID, .5
phy set rigid body sleep linear velocity ID,slv#
phy set rigid body sleep angular velocity ID, slv#
phy set rigid body ccd id,1
inc id
time2=timer()
endif
`position object cursorobj,objx#+pickdiffx#,objy#+pickdiffy#,objz#+pickdiffz#
else
pickdiffx#=pickdiffx#+mousemovey()
pickdiffy#=pickdiffy#+mousemovex()
grid=0
if grid=1
tpickdiffx#=int(pickdiffx#/22.5)*22.5
tpickdiffy#=int(pickdiffy#/22.5)*22.5
else
tpickdiffx#=pickdiffx#
tpickdiffy#=pickdiffy#
endif
` rotate object cursorobj,wrapvalue(objx#-tpickdiffx#),wrapvalue(objy#-tpickdiffy#),objz#
endif
endif
endif
return
Dark Physics makes any hot drink go cold.