Here is some bounding box code. This is about as simple as it comes, what it does is get the position of the object in the x# and z# variables, checks if they are out of the specified area and if so, sets them back to the edge of that area. Note that the actual wall objects are just there for decoration in this demo. To change the bounding box, you need to change the values in the group of if statements that checks the variables.
` turn on manual sync
sync on
` make and position player sphere
make object sphere 1,10
position object 1,0,0,0
` make wall objects
make object box 10,100,10,10
make object box 11,100,10,10
make object box 12,10,10,100
make object box 13,10,10,100
` position wall objects
position object 10,0,0,50
position object 11,0,0,-50
position object 12,50,0,0
position object 13,-50,0,0
` position and point camera
position camera 0,100,0
point camera 0,0,0
` start main loop
do
` control sphere
if upkey()=1 then move object 1,1
if downkey()=1 then move object 1,-1
if leftkey()=1 then turn object left 1,2
if rightkey()=1 then turn object right 1,2
` get sphere positions
x#=object position x(1)
z#=object position z(1)
` check if positions are out of confined area
` if so, set the position variables to what they should be
if x#>40 then x#=40
if x#<-40 then x#=-40
if z#>40 then z#=40
if z#<-40 then z#=-40
` finally position the object using the variables
position object 1,x#,object position y(1),z#
` refresh the screen
sync
` start loop again
loop
Cheers.
My 1337 site: