sync on
phy start
phy set continuous cd 1.0
make object box 1,2000,50,2000
make object box 2,2000,50,2000
make object box 3,50,2000,2000
make object box 4,50,2000,2000
make object box 5,2000,2000,50
make object box 6,2000,2000,50
position object 1,0,-1000,0
position object 2,0,1000,0
position object 3,-1000,0,0
position object 4,1000,0,0
position object 5,0,0,-1000
position object 6,0,0,1000
phy make rigid body static box 1
phy make rigid body static box 2
phy make rigid body static box 3
phy make rigid body static box 4
phy make rigid body static box 5
phy make rigid body static box 6
for d = 7 to 100
make object box d,rnd(100)+20,rnd(100)+20,rnd(100)+20
color object d,rgb(rnd(255),rnd(255),rnd(255))
rotate object d,rnd(360),rnd(360),rnd(360)
position object d,rnd(400)-rnd(400),rnd(400)-rnd(400),rnd(400)-rnd(400)
phy make rigid body dynamic box d
next d
make object box 101,1,1,10
make object box 102,0.6,0.6,2000
color object 101,rgb(0,0,255)
color object 102,rgb(255,0,0)
ghost object on 102
position object 101,0,-2,0
position object 102,0,-2,0
disable object zdepth 101
lock object on 101
lock object on 102
make object box 103,50,50,100
make object box 104,50,50,100
hide object 103
hide object 104
phy make rigid body dynamic box 103
PHY SET RIGID BODY KINEMATIC 103,1
x1 as double float
y2 as double float
z3 as double float
x1 as double float
y2 as double float
z3 as double float
mag as double float
do
move camera (upkey()-downkey())*2
move camera right (rightkey()-leftkey())*2
inc rotx#,mousemovey()
inc roty#,mousemovex()
rotate camera rotx#,roty#,0
if mouseclick()=1
show object 102
roll object right 102,5
x1 = camera position x()
y1 = camera position y()
z1 = camera position z()
phy set rigid body kinematic rotation 103,camera angle x(),camera angle y(),camera angle z()
rotate object 104,camera angle x(),camera angle y(),camera angle z()
if possed
move object 104,50
phy set rigid body kinematic position 103,object position x(104),object position y(104),object position z(104)
inc possed
if possed > 50
possed = 0
endif
else
phy set rigid body kinematic position 103,x1,y1,z1
position object 104,x1,y1,z1
inc possed
endif
else
if mouseclick()=2
show object 102
roll object right 102,5
for d = 7 to 100
x# = object position x(d)
y# = object position y(d)
z# = object position z(d)
dk convert 2d to 3d 0,screen width()/2,screen height()/2,700
x1 = dk get pick vector x()-x#
y1 = dk get pick vector y()-y#
z1 = dk get pick vector z()-z#
xv# = phy get rigid body linear velocity x(d)*0.996
yv# = phy get rigid body linear velocity y(d)*0.996
zv# = phy get rigid body linear velocity z(d)*0.996
inc xv#,x1*0.01
inc yv#,y1*0.01
inc zv#,z1*0.01
ang# = atanfull(x1,z1)+90
inc xv#,sin(ang#)*0.2
inc zv#,cos(ang#)*0.2
ang# = atanfull(y1,z1)+90
inc yv#,sin(ang#)*0.2
inc zv#,cos(ang#)*0.2
phy set rigid body linear velocity d,xv#,yv#,zv#
next d
else
if mouseclick()=3
show object 102
roll object right 102,5
for d = 7 to 100
x# = object position x(d)
y# = object position y(d)
z# = object position z(d)
dk convert 2d to 3d 0,screen width()/2,screen height()/2,700
x1 = dk get pick vector x()-x#
y1 = dk get pick vector y()-y#
z1 = dk get pick vector z()-z#
xv# = phy get rigid body linear velocity x(d)*1.01
yv# = phy get rigid body linear velocity y(d)*1.01
zv# = phy get rigid body linear velocity z(d)*1.01
dec xv#,x1*0.1
dec yv#,y1*0.1
dec zv#,z1*0.1
ang# = atanfull(x1,z1)+90
inc xv#,sin(ang#)*0.5
inc zv#,cos(ang#)*0.5
ang# = atanfull(y1,z1)+90
inc yv#,sin(ang#)*0.5
inc zv#,cos(ang#)*0.5
phy set rigid body linear velocity d,xv#,yv#,zv#
next d
else
hide object 102
endif
endif
endif
phy update
sync
loop
Attached is the exe
Controls:
Arrowkeys to move
Mouse to look
Left-click to shoot away objects
Right-click to pull the objects together into a rotating ball
Left+Right-click to repel objects from ball