They will behave that way because dynamic physics bodies will push themselves away from each other
in all/any directions
ie an exploding block without physics can be acheived
SetWindowTitle( "Explosion" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
#constant KEY_SPACE = 32 //the space bar
#constant KEY_LEFT = 37 //the left arrow key scancode
#constant KEY_UP = 38 //the up arrow key scancode
#constant KEY_RIGHT = 39 //the right arrow key scancode
#constant KEY_DOWN = 40 //the down arrow key scancode
SetGenerateMipmaps( 1 )
type face
ID as integer
x as float
y as float
z as float
xOld as float
yOld as float
zOld as float
xAng as float
yAng as float
zAng as float
xAngOld as float
yAngOld as float
zAngOld as float
time as float //to be implimented
endtype
global faces as face[]
CreateObjectBox(10,2,2,2)
SetObjectColor(10,0,255,0,255)
// main loop
do
if GetRawKeyState(KEY_LEFT) then MoveObjectLocalX(10,-1)
if GetRawKeyState(KEY_RIGHT) then MoveObjectLocalX(10,1)
if GetRawKeyState(KEY_UP) then MoveObjectLocalY(10,1)
if GetRawKeyState(KEY_DOWN) then MoveObjectLocalY(10,-1)
if GetRawKeyPressed(KEY_SPACE) then explosionSetup(10)
if faces.length+1 >0 then updateExplosion()
//if faces.length <=1 then explosionSetup(10)
if faces.length <=1 then SetObjectVisible(10,1)
Print ("Move green block with arrow keys")
Print ("Press space to self destruct")
sync()
loop
function updateExplosion()
SetObjectVisible(10,0)
for num =0 to faces.length-1
SetObjectVisible(faces[num].ID,1)
if faces[num].x > faces[num].xOld
offsetX=random(0,1)
else
offsetX=-random(0,1)
endif
if faces[num].y > faces[num].yOld
offsetY=random(0,1)
else
offsetY=-random(0,1)
endif
if faces[num].z > faces[num].zOld
offsetZ=random(0,1)
else
offsetZ=-random(0,1)
endif
SetObjectPosition(faces[num].ID,faces[num].x+offsetX,faces[num].y+offsetY,faces[num].z+offsetZ)
faces[num].x=GetObjectX(faces[num].ID)
faces[num].y=GetObjectY(faces[num].ID)
faces[num].z=GetObjectZ(faces[num].ID)
if faces[num].xAng > faces[num].xAngOld
offsetAngX=random(0,10)
else
offsetAngX=-random(0,10)
endif
if faces[num].yAng > faces[num].yAngOld
offsetAngY=random(0,10)
else
offsetAngY=-random(0,10)
endif
if faces[num].zAng > faces[num].zAngOld
offsetAngZ=random(0,10)
else
offsetAngZ=-random(0,10)
endif
SetObjectRotation(faces[num].ID,faces[num].xAng+offsetAngX,faces[num].yAng+offsetAngY,faces[num].zAng+offsetAngZ)
faces[num].xAng=GetObjectAngleX(faces[num].ID)
faces[num].yAng=GetObjectAngleY(faces[num].ID)
faces[num].zAng=GetObjectAngleZ(faces[num].ID)
if timer()>faces[num].time+1
deleteObject(faces[num].ID)
faces.remove(num)
endif
next num
endfunction
function explosionSetup(id as integer)
myFace as face
myFace.ID=CreateObjectBox(2,2,.25)
SetObJectPosition(myFace.ID,getObjectX(id),getObjectY(id),getObjectZ(id)+1)
SetObjectRotation(myFace.ID,getObjectAngleX(id),GetObjectAngleY(id),GetObjectAngleZ(id))
SetObjectVisible(myFace.ID,0)
SetObjectcolor(myFace.ID,255,0,0,255)
MyFace.x=GetObjectX(myFace.ID)
MyFace.y=GetObjectY(myFace.ID)
MyFace.z=GetObjectZ(myFace.ID)
MyFace.xAng=GetObjectAngleX(myFace.ID)
MyFace.yAng=GetObjectAngleY(myFace.ID)
MyFace.zAng=GetObjectAngleZ(myFace.ID)
myFace.xOld=myFace.x
myFace.yOld=myFace.y
myFace.zOld=myFace.z
MyFace.xAngOld=myFace.xAng
MyFace.yAngOld=myFace.yAng
MyFace.zAngOld=myFace.zAng
MyFace.time=timer()
faces.insert(myFace)
myFace.ID=CreateObjectBox(2,2,.25)
SetObJectPosition(myFace.ID,getObjectX(id),getObjectY(id),getObjectZ(id)-1)
SetObjectRotation(myFace.ID,getObjectAngleX(id),GetObjectAngleY(id),GetObjectAngleZ(id))
SetObjectVisible(myFace.ID,0)
SetObjectcolor(myFace.ID,255,0,0,255)
MyFace.x=GetObjectX(myFace.ID)
MyFace.y=GetObjectY(myFace.ID)
MyFace.z=GetObjectZ(myFace.ID)
MyFace.xAng=GetObjectAngleX(myFace.ID)
MyFace.yAng=GetObjectAngleY(myFace.ID)
MyFace.zAng=GetObjectAngleZ(myFace.ID)
myFace.xOld=myFace.x
myFace.yOld=myFace.y
myFace.zOld=myFace.z
MyFace.xAngOld=myFace.xAng
MyFace.yAngOld=myFace.yAng
MyFace.zAngOld=myFace.zAng
MyFace.time=timer()
faces.insert(myFace)
myFace.ID=CreateObjectBox(.25,2,2)
SetObJectPosition(myFace.ID,getObjectX(id)-1,getObjectY(id),getObjectZ(id))
SetObjectRotation(myFace.ID,getObjectAngleX(id),GetObjectAngleY(id),GetObjectAngleZ(id))
SetObjectVisible(myFace.ID,0)
SetObjectcolor(myFace.ID,255,0,0,255)
MyFace.x=GetObjectX(myFace.ID)
MyFace.y=GetObjectY(myFace.ID)
MyFace.z=GetObjectZ(myFace.ID)
MyFace.xAng=GetObjectAngleX(myFace.ID)
MyFace.yAng=GetObjectAngleY(myFace.ID)
MyFace.zAng=GetObjectAngleZ(myFace.ID)
myFace.xOld=myFace.x
myFace.yOld=myFace.y
myFace.zOld=myFace.z
MyFace.xAngOld=myFace.xAng
MyFace.yAngOld=myFace.yAng
MyFace.zAngOld=myFace.zAng
MyFace.time=timer()
faces.insert(myFace)
myFace.ID=CreateObjectBox(.5,2,2)
SetObJectPosition(myFace.ID,getObjectX(id)+1,getObjectY(id),getObjectZ(id))
SetObjectRotation(myFace.ID,getObjectAngleX(id),GetObjectAngleY(id),GetObjectAngleZ(id))
SetObjectVisible(myFace.ID,0)
SetObjectcolor(myFace.ID,255,0,0,255)
MyFace.x=GetObjectX(myFace.ID)
MyFace.y=GetObjectY(myFace.ID)
MyFace.z=GetObjectZ(myFace.ID)
MyFace.xAng=GetObjectAngleX(myFace.ID)
MyFace.yAng=GetObjectAngleY(myFace.ID)
MyFace.zAng=GetObjectAngleZ(myFace.ID)
myFace.xOld=myFace.x
myFace.yOld=myFace.y
myFace.zOld=myFace.z
MyFace.xAngOld=myFace.xAng
MyFace.yAngOld=myFace.yAng
MyFace.zAngOld=myFace.zAng
MyFace.time=timer()
faces.insert(myFace)
myFace.ID=CreateObjectBox(2,2,.25)
SetObJectPosition(myFace.ID,getObjectX(id),getObjectY(id)+1,getObjectZ(id))
SetObjectRotation(myFace.ID,getObjectAngleX(id)+90,GetObjectAngleY(id),GetObjectAngleZ(id))
SetObjectVisible(myFace.ID,0)
SetObjectcolor(myFace.ID,255,0,0,255)
MyFace.x=GetObjectX(myFace.ID)
MyFace.y=GetObjectY(myFace.ID)
MyFace.z=GetObjectZ(myFace.ID)
MyFace.xAng=GetObjectAngleX(myFace.ID)
MyFace.yAng=GetObjectAngleY(myFace.ID)
MyFace.zAng=GetObjectAngleZ(myFace.ID)
myFace.xOld=myFace.x
myFace.yOld=myFace.y
myFace.zOld=myFace.z
MyFace.xAngOld=myFace.xAng
MyFace.yAngOld=myFace.yAng
MyFace.zAngOld=myFace.zAng
MyFace.time=timer()
faces.insert(myFace)
myFace.ID=CreateObjectBox(2,2,.25)
SetObJectPosition(myFace.ID,getObjectX(id),getObjectY(id)-1,getObjectZ(id))
SetObjectRotation(myFace.ID,GetObjectAngleX(id)+90,getObjectY(id),getObjectZ(id))
SetObjectVisible(myFace.ID,0)
SetObjectcolor(myFace.ID,255,0,0,255)
MyFace.x=GetObjectX(myFace.ID)
MyFace.y=GetObjectY(myFace.ID)
MyFace.z=GetObjectZ(myFace.ID)
MyFace.xAng=GetObjectAngleX(myFace.ID)
MyFace.yAng=GetObjectAngleY(myFace.ID)
MyFace.zAng=GetObjectAngleZ(myFace.ID)
myFace.xOld=myFace.x
myFace.yOld=myFace.y
myFace.zOld=myFace.z
MyFace.xAngOld=myFace.xAng
MyFace.yAngOld=myFace.yAng
MyFace.zAngOld=myFace.zAng
MyFace.time=timer()
faces.insert(myFace)
for num =0 to faces.length-1
faces[num].x=faces[num].x+Random2(-2,2)
faces[num].y=faces[num].y+Random2(-2,2)
faces[num].z=faces[num].z+Random2(-2,2)
faces[num].xAng=faces[num].xAng+Random2(-2,2)
faces[num].yAng=faces[num].yAng+Random2(-2,2)
faces[num].zAng=faces[num].zAng+Random2(-2,2)
next num
endfunction
to do a crumble effect I personally think if you moved the pieces until the collided inward you would get a crumble effect
I cant see it will work properly with dynamic objects but i could be wrong
fubar