Here's a simple third person camera:
`Set the screen refresh rate
sync on
sync rate 60
`Make a 'floor', so we will be able to see that our object actually moves
make matrix 1, 100, 100, 10, 10
`Make a player object
make object cube 1, 5
`Main loop
do
`Simple controls
`if 'w', move forward
if keystate(17)
move object 1, 2
endif
`if 's', move backward
if keystate(31)
move object 1, -2
endif
`if 'd', turn right
if keystate(32)
turn object right 1, 3
endif
`if 'a', turn left
if keystate(30)
turn object left 1, 3
endif
`Call the function that will make the camera follow our player object
cam_follow(0, 1, 25, 10)
`refresh the screen
sync
loop
`The function that makes the camera follow an object.
`camNumber is the number of the camera
`obejctNumber is the number of the object you want the camera to follow
`distance is how far away from the object you want the camera
`height is, well, the difference in height between your camera and your object
function cam_follow(camNumber AS integer, objectNumber AS integer, distance AS integer, height AS integer)
`First, position the camera in the objects position, and move it a little upward
position camera camNumber, object position x(objectNumber), object position y(objectNumber)+height, object position z(objectNumber)
`Then rotate the camera according to the objects angles
rotate camera camNumber, object angle x(objectNumber), object angle y(objectNumber), object angle z(objectNumber)
`Finally adjust the camera according to the wanted distance
move camera camNumber, -distance
endfunction
I'll comment the code in a second or two.
EDIT: Commented the code.