Hi. I am working on a game but I need help with collisions, I don't know what I am doing wrong. I made a Direct X object for map and X object for player but collisions won't work.
sync on
sync rate 60
dwidth=desktop width()
dheight=desktop height()
set display mode dwidth,dheight,32,1
hide mouse
set global collision on
gosub makeobjects
rem texturesize=0
rem map$="levelbank\testlevel\level1\universe.dbo"
rem load static objects map$,texturesize
load object "media\nikimap.x",10
make object collision box 1, -5,-5,-5,5,5,5,0
make object collision box 10, -5,-5,-5,5,5,5,0
scale object 10,350,350,350
position object 10,0,0,0
while escapekey()=0
coll=object hit(1,10)
if coll=1 then move object 1,-10
gosub controls
set point light 0,camera position x(),camera position y()+50,camera position z()
sync
endwhile
set global collision off
delete object collision box 1
delete object collision box 10
end
controls:
walk=0
if keystate(17)=1 and object hit(1,10)=0 then move object 1,4 : walk=1
if keystate(31)=1 and object hit(1,10)=0 then move object 1,-4 : walk=1
if keystate(30)=1 and object hit(1,10)=0 then yrotate object 1,wrapvalue(object angle y(1)-4) : walk=1
if keystate(32)=1 and object hit(1,10)=0 then yrotate object 1,wrapvalue(object angle y(1)+4) : walk=1
x#=object position x(1)
y#=object position y(1)
z#=object position z(1)
a#=object angle y(1)
d#=250.0
h#=185.0
s#=50.0
set camera to follow x#,y#,z#,a#,d#,h#,s#,1
set point light 0,camera position x(),camera position y()+50,camera position z()
return
makeobjects:
rem load object "files\sky\cloudcube.x",3
rem position object 3,0,0,0
rem set object texture 3,2,1
rem set object light 3,1
rem yrotate object 3,270
rem scale object 3,30000,30000,30000
rem position object 3,1250,100,-1250
set ambient light 100
position camera 400,250,600
load music "media\sfx\niki_menu.mp3",1
loop music 1
load object "media\hero\niki_1.x",1
scale object 1,80,80,80
set object specular 1,0
position object 1,50,50,-30
yrotate object 1,180
fix object pivot 1
rotate object 1,0,180,0
set object speed 1,10000
make object collision box 1,-40,0,-40,40,150,40,0
position object 1,50,0,-50
yrotate object 1,90
return
Thanks for advance!
See my dragon here <a href='http://dragcave.net/view/7QnA'><img src='http://dragcave.net/image/7QnA.gif' style='border-width: 0' alt='Adopt one today!'/></a>