It seems it would be easier to use the object collision commands to check if indeed the player has moved into a wall or to the teleport spot. Before the player moves, store the x#, y# and z# coordinates for the player object. You then move the player and check to see if a collision with a wall occurred. If it does, you place it back where it was originally.
Regarding the teleport spot, if you determine the player is at the teleport spot, you simply position the player object where you want it to go. I whipped up a very quick example:
`19 May 2012, LBFN for Fear For Hire
sync on : sync rate 60 : autocam off
// player
make object sphere 1,5 : position object 1,75.0,2.5,75.0
// walls
restore WallData
for g = 2 to 5
make object box g,100,30,10
read rAng#,x#,y#,z#
yrotate object g,rAng#
position object g,x#,y#,z#
color object g,rgb(255,0,0)
next g
make object plane 6,105.0,105.0
position object 6,100.0,0.0,100.0
color object 6,rgb(0,200,0)
xrotate object 6,90.0 : fix object pivot 6
clone object 7,6
position object 7,200.0,0.0,100.0
position camera 75.0,220.0,75.0
point camera 75.0,2.5,75.0
repeat
MovePlayer()
Debug()
sync
until mouseclick() > 0
end
function MovePlayer()
oldX# = object position x(1)
oldY# = object position y(1)
oldZ# = object position z(1)
if upkey() = 1
move object 1,2.0
endif
if downkey() = 1
move object 1,-2.0
endif
if leftkey() = 1
position object 1,oldX# - 2.0,oldY#,oldZ#
endif
if rightkey() = 1
position object 1,oldX# +2.0,oldY#,oldZ#
endif
collide = object collision(1,0)
if collide > 0 and collide < 6
text 100,10,"collide = " + str$(collide)
position object 1,oldX#,oldY#,oldZ#
endif
if abs(object position x(1) - 147.0) < 3.0
if abs(object position z(1) - 59.0) < 3.0
// arrived at the teleport spot - move to the next room
position object 1,200,2.5,75.0
endif
endif
endfunction
function Debug()
text 10,10,"FPS: " + str$(screen fps() )
text 10,100,"X#: " + str$(object position x(1))
text 10,120,"Z#:" + str$(object position z(1))
text 200,10,"Teleport spot is at 147, 59"
endfunction
WallData:
// rotate angle, x#, y#,z#
data 0.0,100.0,15.0,50.0
data 90.0,155.0,15.0,100.0
data 0.0,105.0,15.0,150.0
data 90.0,50.0,15.0,105.0
Bear in mind, this is a
very crude example that I put together in a few minutes. You move the player sphere using the arrow keys. If you hit a wall, the player will not advance and it will tell you the object number you are colliding with. If you get to the 'teleport spot' at 147, 59 (x and z), it will move you to the next room.
So many games to code.......so little time.