OK, here is my complete code example. Put it in the folder with Sparky's and watch it not work.
`Setup
hide mouse
sync on
sync rate 60
backdrop on
color backdrop 0
autocam off
`Make player and set it up for collision
make object sphere 1,4
position object 1,50,10,50
setupObjectDBC(1,1,1)
`Make level and set it up for collision
make object sphere 2,100
color object 2,255
position object 2,0,-50,0
setupObjectDBC(2,1,0)
`Start control loop
do
`Call player control/collision function
control(.02,.3,.3,3,4.)
sync
loop
`End loop
end
`functions-----------
`Player control/collision function
`g#=Gravity, j#=Jump strength, s#=Speed, r=Rotational speed, damp#=Mouse damper
function control(g#,j#,s#,r,damp#)
oay#=object angle y(1):x#=object position x(1):y#=object position y(1):z#=object position z(1)
if scancode() then yrotate object 1,ay#
if keystate(17)>0 then move object 1,s#
if upkey()>0 and keystate(17)=0 then move object 1,s#
if keystate(31)>0 then move object 1,s#*-1
if downkey()>0 and keystate(31)=0 then move object 1,s#*-1
if keystate(32)>0
if upkey()=0 and downkey()=0 and keystate(17)=0 and keystate(31)=0
yrotate object 1,wrapvalue(object angle y(1)+90)
move object 1,s#:yrotate object 1,wrapvalue(object angle y(1)-90)
endif
if keystate(17)>0 then move object 1,-1*s#:yrotate object 1,wrapvalue(object angle y(1)+45):move object 1,s#:yrotate object 1,wrapvalue(object angle y(1)-45)
if keystate(31)>0 then move object 1,s#:yrotate object 1,wrapvalue(object angle y(1)-45):move object 1,-1*s#:yrotate object 1,wrapvalue(object angle y(1)+45)
endif
if rightkey()>0 then ay#=wrapvalue(ay#+r)
if keystate(30)>0
if upkey()=0 and downkey()=0 and keystate(17)=0 and keystate(31)=0
yrotate object 1,wrapvalue(object angle y(1)-90)
move object 1,s#:yrotate object 1,wrapvalue(object angle y(1)+90)
endif
if keystate(17)>0 and keystate(31)=0 then move object 1,-1*s#:yrotate object 1,wrapvalue(object angle y(1)-45):move object 1,s#:yrotate object 1,wrapvalue(object angle y(1)+45)
if keystate(31)>0 and keystate(17)=0 then move object 1,s#:yrotate object 1,wrapvalue(object angle y(1)+45):move object 1,-1*s#:yrotate object 1,wrapvalue(object angle y(1)-45)
endif
if leftkey()>0 then ay#=wrapvalue(ay#-r)
ay#=wrapvalue(ay#+(mousemovex()/damp#))
if spacekey() then position object 1,object position x(1),object position y(1)+j#,object position z(1)
f#=f#-g#:position object 1,object position x(1),object position y(1)+f#,object position z(1)
updateObjectDBC(1)
col=intersectObjectDBC(1,1,x#,y#,z#,object position x(1),object position y(1),object position z(1),1)
position object 1,getStaticCollisionX(),getStaticCollisionY(),getStaticCollisionZ()
show object 1
if mouseclick()>1
hide object 1
ax#=wrapvalue(camera angle x()+(mousemovey()/damp#))
ay#=wrapvalue(object angle y(1)+(mousemovex()/damp#))
if ax#<270 and ax#>180 then ax#=270
if ax#>90 and ax#<180 then ax#=90
position camera object position x(1),object size y(1)+object position y(1),object position z(1)
yrotate object 1,ay#:rotate camera ax#,ay#,0
else
set camera to follow object position x(1),object size y(1)+object position y(1),object position z(1),ay#,object size y(1)*1.7,object size y(1)*1.5+object position y(1),2,0
point camera object position x(1),object size y(1)+object position y(1),object position z(1)
endif
position listener camera position x(),camera position y(),camera position z()
rotate listener camera angle x(),camera angle y(),camera angle z()
text 0,0,str$(col)
endfunction
`End player control/collision function
`Start Sparky's functions
function setupObjectDBC(objNum,groupNum,objectType)
commonSetup(objNum)
vertData = get memblock ptr(254)
objectData = get memblock ptr(255)
call dll 1,"setupObject",objNum,groupNum,objectType,vertData,objectData
delete memblock 254
endfunction
function setupComplexObjectDBC(objNum,groupNum,facesPerNode)
commonSetup(objNum)
vertData = get memblock ptr(254)
objectData = get memblock ptr(255)
call dll 1,"setupComplexObject",objNum,groupNum,facesPerNode,vertData,objectData
delete memblock 254
endfunction
function commonSetup(objNum)
if dll exist(1)=0 then load dll "DBCcollision.dll",1
if memblock exist(255)=0 then make memblock 255,24
x#=object position x(objNum)
y#=object position y(objNum)
z#=object position z(objNum)
angx#=object angle x(objNum)
angy#=object angle y(objNum)
angz#=object angle z(objNum)
write memblock float 255,0,x#
write memblock float 255,4,y#
write memblock float 255,8,z#
write memblock float 255,12,angx#
write memblock float 255,16,angy#
write memblock float 255,20,angz#
position object objNum,0,0,0
rotate object objNum,0,0,0
make mesh from object 255,objNum
make memblock from mesh 254,255
delete mesh 255
position object objNum,x#,y#,z#
rotate object objNum,angx#,angy#,angz#
endfunction
function updateObjectDBC(objNum)
if memblock exist(255)=0 then make memblock 255,24
write memblock float 255,0,object position x(objNum)
write memblock float 255,4,object position y(objNum)
write memblock float 255,8,object position z(objNum)
write memblock float 255,12,object angle x(objNum)
write memblock float 255,16,object angle y(objNum)
write memblock float 255,20,object angle z(objNum)
objectData = get memblock ptr(255)
call dll 1,"updateObject",objNum,objectData
endfunction
function intersectObjectDBC(objNum,groupFlag,oldx#,oldy#,oldz#,x#,y#,z#,excludeObj)
collide=call dll(1,"intersectObject",objNum,groupFlag,oldx#,oldy#,oldz#,x#,y#,z#,excludeObj)
endfunction collide
function setObjectCollisionOnDBC(objNum)
call dll 1,"set_object_collision_on",objNum
endfunction
function setObjectCollisionOffDBC(objNum)
call dll 1,"set_object_collision_off",objNum
endfunction
function collisionStatusDBC(objNum)
result=call dll(1,"collisionstatus",objNum)
endfunction result
function getStaticCollisionX()
result#=call dll(1,"getStaticCollisionX")
endfunction result#
function getStaticCollisionY()
result#=call dll(1,"getStaticCollisionY")
endfunction result#
function getStaticCollisionZ()
result#=call dll(1,"getStaticCollisionZ")
endfunction result#
function getCollisionNormalX()
result#=call dll(1,"getCollisionNormalX")
endfunction result#
function getCollisionNormalY()
result#=call dll(1,"getCollisionNormalY")
endfunction result#
function getCollisionNormalZ()
result#=call dll(1,"getCollisionNormalZ")
endfunction result#
EDIT: Code updated to meet standards.