how do I get 1000 object to collide and give feed back from each collision?
I need to fix this
SPA(c).col1 = c or SPA(c).col2 = c so that all object change colour when a collision takes place
here is the code I`ve used so far, how do I fix this?
sync on : sync rate 60
phy start
autocam off
rotate camera 45,0,0
position camera 0,0,-20
type spin_top
col1 as Integer
col2 as Integer
endtype
dim SPA(1000) as spin_top
for c = 1 to 1000
make object cube c,1
position object c,rnd(20)-rnd(20),rnd(20)-rnd(20),rnd(20)-rnd(20)
color object c,rgb(255,0,0)
phy make rigid body dynamic box c
next c
make object cube 1001,1
scale object 1001,10000,10,10000
position object 1001,0,-30,0
phy make rigid body static box 1001
ink rgb(0,0,0),0
do
for c = 1 to 1000
while phy get collision data ( )
SPA(c).col1 = phy get collision object a ( )
SPA(c).col2 = phy get collision object b ( )
if SPA(c).col1 = c or SPA(c).col2 = c :`HERE IS WHERE I NEED HELP
color object c,rgb(0,255,0)
set cursor 0,100 : print "collision ";c
else
color object c,rgb(255,0,0)
endif
set cursor 0,60 : print "collision A: ";SPA(c).col1
set cursor 0,80 : print "collision B: ";SPA(c).col2
endwhile
next c
phy update
sync
loop
thanks in advance
Edit
I got the collisions to work like a dream here is the code
sync on : sync rate 60
set display mode 1280,800,32
backdrop on
color backdrop rgb(255,255,255)
autocam off
rotate camera 45,0,0
position camera 0,0,-40
phy start
type spin_top
col1 as Integer
endtype
dim SPA(10000) as spin_top
for c = 1 to 1000
make object cube c,1
position object c,rnd(20)-rnd(20),rnd(20)-rnd(20),rnd(20)-rnd(20)
color object c,rgb(255,0,0)
phy make rigid body dynamic box c
next c
make object cube 1001,1
scale object 1001,10000,10,10000
position object 1001,0,-30,0
hide object 1001
phy make rigid body static box 1001
ink rgb(0,0,0),0
do
set cursor 0,0 : print "FPS: ";screen fps()
set cursor 0,20 : print "Press space bar to re-set"
set cursor 0,40 : print "Press P key to pause physic"
gosub collisions
gosub camera
gosub physic_pause
sync
loop
`*******************************************************************************************************
`********************************((( here is the collision code ))**************************************
`*******************************************************************************************************
collisions:
for c = 1 to 1000
while phy get collision data ( )
a = phy get collision object a ( )
b = phy get collision object b ( )
if a > 0 and b > 0 and a < 1001 and b < 1001 and (SPA(a).col1 = 0 or SPA(b).col1 = 0)
color object a,rgb(0,255,0)
color object b,rgb(0,0,255)
SPA(a).col1 = 1
SPA(b).col1 = 1
else
color object c,rgb(255,0,0)
SPA(a).col1 = 0
SPA(b).col1 = 0
endif
endwhile
if spacekey()=1
color object c,rgb(255,0,0)
phy set rigid body position c,rnd(20)-rnd(20),rnd(20)-rnd(20),rnd(20)-rnd(20)
phy set rigid body rotation c,0,0,0
endif
next c
return
`*******************************************************************************************************
`*******************************((( here is the pause physic code ))************************************
`*******************************************************************************************************
physic_pause:
if keystate(25) = 1 and pause = 0 then pause = 1
if pause = 1
set cursor screen width()/2.25,screen height()/2.25 :print "Physic Paused"
inc count
if count >= 25
if keystate(25) = 1 then pause = 0
endif
else
count = 0
phy update
endif
return
`*******************************************************************************************************
`*******************************((( here is the mad camera contol ))************************************
`*******************************************************************************************************
camera:
c# = wrapvalue( c# + 0.5 )
x# = cos ( c# ) * 40.0
z# = sin ( c# ) * 40.0
position camera x#, x#, z#
point camera 0.0,-20,0.0
return
soul sucking devils, twisted body of the damed, slivering slim drips from every poor, sin licking at your ears, and the smell stinging your eyes, and if you don't like it, get out of my kitchen!