I am really having trouble with this intersect object command. I am trying to make it so that when you run into the cubes, you stop. But whenever I turn the intersect object number tuns to zero, and for some reason, it isn't even detecting collision on the walls. I need some help please!
Code:
`Set Up the Background
Sync On
Backdrop On
Color Backdrop Black
Autocam Off
`Variables
x#=0 : y#= 15 : z#=0
`Make the Charecter
Make Object Sphere 200,3
Color object 200,rgb(0,100,0)
x=0
z=0
`Make The Ground Cubes
For cubes=1 to 25
Make Object Cube cubes,40
Scale Object cubes,100,50,100
Position object cubes,x,y,z
Color Object cubes,rgb(200,0,0)
Make Object Collision Box cubes,-22,-20,-22,22,20,22,0
x=x+40
if x=160
x=0 : z=z+40
endif
if z=160 then y=15
Next cubes
`Main Loop
Do
`Movement + Position
Position Object 200,x#,y#,z#
`Movement + Keys
a#=object angle y(200)
oldx1#=x# : oldz1#=z#
if upkey()=1 then x#=newxvalue(x#,a#,.5) : z#=newzvalue(z#,a#,.5)
if downkey()=1 then x#=newxvalue(x#,a#,-.5) : z#=newzvalue(z#,a#,-.5)
if leftkey()=1 then yrotate object 200,wrapvalue(object angle y(200)-1)
if rightkey()=1 then yrotate object 200,wrapvalue(object angle y(200)+1)
`The Light Changer
`So you stay on the blocks
oldx#=x# : oldz#=z#
x#=newxvalue(x#,a#,10) : z#=newzvalue(z#,a#,10)
col=intersect object(200,oldx#,20,oldz#,x#,20,z#)
If col=1
x#=oldx1# : z#=oldz1#
gosub rest
endif
x#=oldx# : z#=oldz#
gosub rest
rest:
Set Cursor 10,10
Print ": ",col
If x#<-200 then x#=-200
If x#>200 then x#=200
If z#<-180 then z#=-180
If z#>220 then z#=220
`Camera things
Set Camera to Follow x#,y#,z#,a#,10,5,10,1
`Refresh the screen
Sync
`End of Loop
Loop
`Terminate Program!
End
Am I dead yet?