I\\\'m making a Doom style game, which means it is in first person and uses 2d images on object plains, and 3d objects. I want to know how to detect a 3d object colliding with a object plain to stop the camera from going through the wall along with the object. I set it so there is an object where the camera is. The problem with the collision is that when the object hits the plane it moves me to the same every time. I have no idea why and i would appreciate help.
CLS
hide mouse
sync on
a=122
rem fog
fog off
fog color 0
fog distance 3000
rem Make a matrix
backdrop on
load image \\\\\\\"enemy2.bmp\\\\\\\",4
spritexx=500
spriteyy=500
load image \\\\\\\"shotgun.bmp\\\\\\\",5
sprite 2,60,20,5
set sprite 2,0,1
size sprite 2,spritexx,spriteyy
load bitmap \\\\\\\"grass.bmp\\\\\\\",1
get image 1,0,0,256,256
delete bitmap 1
load bitmap \\\\\\\"true bricks.bmp\\\\\\\",2
get image 2,0,0,256,256
delete bitmap 2
load bitmap \\\\\\\"fire.bmp\\\\\\\",3
get image 3,0,0,256,256
delete bitmap 3
load bitmap \\\\\\\"road.bmp\\\\\\\",6
get image 6,0,0,256,256
delete bitmap 6
texture backdrop 3
rem make matrix (matrix number, width, depth, xsegmented, zsegmented)
make matrix 1,1000,3000,25,25
rem set matrix (matrix number,wireframe,transparecy, cull, filter, light, fog, ambient)
set matrix 1,0,50,0,1,50,700,50
rem position matrix (matrix number, x,y,z)
position matrix 1,100,0,200
rem prepare matrix texture (matrix number, image value, across, down)
prepare matrix texture 1,6,2,2
rem Cylinder body
make object cube 6,100
position object 6,camera position x(),camera position y(),camera position z()
Rem Right Wall
make object plain 1,1000,160
position object 1,600,74.8,200
texture object 1,2
rem dude
make object plain 2,100,100
position object 2,500,40,500
texture object 2,4
set object 2,1,0,1
rem last wall
make object plain 3,1000,160
position object 3,600,74.8,3000
texture object 3,2
rem left wall
leftwallx=110
make object plain 4,3000,160
position object 4,100,74.8,1589
texture object 4,2
yrotate object 4,90
rem right wall
make object plain 5,3000,160
position object 5,1000,74.8,1589
texture object 5,2
yrotate object 5,90
set global collision on
set object collision off 2
rem set object collision on 6
position camera 222,70,352
q#=camera position x()
w#=camera position y()
v#=camera position z()
oldx#=q#
oldz#=v#
oldy#=y#
rem Load a wav sound file into number one
load sound \\\\\\\"mr80028.wav\\\\\\\",1
play sound 1
if object exist(6) then print \\\\\\\"fmlksfmlkglfdg\\\\\\\"
rem Begin loop
do
q#=camera position x()
v#=camera position z()
oldx#=q#
oldz#=v#
position camera oldx#,70,oldz#
if object collision(6,0)>0
position camera oldx#,70,oldx#
position object 6,oldx#,camera position y(),oldx#
endif
rem Control camera with arrow keys
if camera position z()=leftwallx
move camera -3.0
endif
if upkey()=1
zrotate object 6,cz#
q#=camera position x()
v#=camera position z()
oldx#=q#
oldz#=v#
move camera 25.0
position object 6,camera position x(),camera position y(),camera position z()
ENDIF
if downkey()=1
q#=camera position x()
v#=camera position z()
oldx#=q#
oldz#=v#
zrotate object 6,cz#
move camera -25.0
position object 6,camera position x(),camera position y(),camera position z()
ENDIF
if leftkey()=1 then angley#=wrapvalue(angley#-2.0)
if rightkey()=1 then angley#=wrapvalue(angley#+2.0)
rem x=x+1
y=y+1
scroll backdrop x,y
rem Update camera
xrotate camera 0.0
yrotate camera angley#
zrotate camera 0.0
rem cx#=wrapvalue(cx#+mousemovey())
cy#=wrapvalue(cy#+mousemovex())
cz#=wrapvalue(cz#+mousemovez())
rotate camera cx#,cy#,cz#
yrotate object 2,cy#
zrotate object 6,cz#
rem Syncronise
sync
loop