Hi there.
@Derek Darkly. I hope you don't mind, I made some arrangements to your snippet. In your code , the camera get stuck in borders , this is correct somehow, but if we want a sliding collision ,we can use:
gosub Setup
do
gosub Movement
gosub DistanceCheck
gosub PrintToScreen
sync
loop
Setup:
sync on:sync rate 60:color backdrop rgb(rnd(100),rnd(100),rnd(100))
WestLimit=-50 `NEGATIVE X
EastLimit=50 `POSITIVE X
SouthLimit=-50 `NEGATIVE Z
NorthLimit=50 `POSITIVE Z
make matrix 1,100,100,20,20:position matrix 1,-50,0,-50 `MAKE A POINT OF REFERENCE
position camera 0,5,0
return
Movement:
ox#=camera position x():oy#=camera position y():oz#=camera position z() `GET OLD POSITION
control camera using arrowkeys 0,0.4,1
x#=camera position x():y#=camera position y():z#=camera position z() `ACTUAL CAMERA POSITION ONCE WE PRESS ARROWKEYS
`camera rotation
a#=wrapvalue(a#+mousemovex()/2)
cam#=wrapvalue(cam#+mousemovey()/2)
rotate camera cam#,a#,0
return
DistanceCheck:
if camera position x()<WestLimit then x#=ox# `IF TOO FAR WEST
if camera position x()>EastLimit then x#=ox# `IF TOO FAR EAST
if camera position z()<SouthLimit then z#=oz# `IF TOO FAR SOUTH
if camera position z()>NorthLimit then z#=oz# `IF TOO FAR NORTH
position camera x#,2,z# `PUT BACK INTO GOOD SPOT ( we could use get ground height )
return
PrintToScreen:
set cursor 0,0
print "Arrowkeys to Move"
print
print "X Position: ";camera position x()
print "Z Position: ";camera position z()
return
Cheers.
I'm not a grumpy grandpa
