Here's a basic example showing a player walking around a terrain with the arrowkeys.
If you have any more questions, you should check this out:
http://forum.thegamecreators.com/?m=forum_view&t=137027&b=7'
`Basic game setup
`This turns control of when the program draws all the stuff to the screen to us
sync on
`This sets the frame rate to 60 (which is usually the accepted value for a game)
sync rate 60
hide mouse
`The easiest way to make a terrain is with a neat object called a matrix
`The matrix is a flat object with a bunch of cells that can be repositioned
`This makes a matrix with ID number 1, width and depth of 80, and 20 cells x 20 cells
make matrix 1,80,80,20,20
`Randomize the matrix, so we get a little elevation and not just flat terrain
randomize matrix 1,5
`Anytime you change a matrix, you have to update it for the changes to take effect
update matrix 1
`This makes a basic sphere with diameter 5 - we can use this as the player
make object sphere 1,5
`How fast the player walks
playerspeed#=0.1
`Main loop - the program will keep repeating this until the player hits escape
DO
`This gets input from the arrowkeys and moves the player accordingly
if upkey()=1 then move object 1,playerspeed#
if downkey()=1 then move object 1,playerspeed#
`This rotates the object based on where the player moves the mouse
yrotate object 1,object angle y(1)+mousemovex()/10
`Now move the object up so it sits on the terrain rather than moving through it
position object 1,object position x(1),get ground height(1,object position x(1),object position z(1))+2.5,object position z(1)
`Finally, position the camera behind the player
`This could be done with trigonometry and stuff but we're going to do it the cheap way
`Position it at the object's location, rotate it properly, and move it back
position camera object position x(1),object position y(1),object position z(1)
yrotate camera object angle y(1)
xrotate camera 45
move camera -30
`We have to call sync to draw to the screen because we used sync on
sync
LOOP