Heres a function that'll handle it all, just fill in the parameters:
FUNCTION handleCamera(cam, moveSpeed#, lookSensitivity#)
ROTATE CAMERA CAMERA ANGLE X(cam) + (MOUSEMOVEY() * lookSensitivity#), CAMERA ANGLE Y(cam) + (MOUSEMOVEX() * lookSensitivity#), 0
MOVE CAMERA cam,(KEYSTATE(17)-KEYSTATE(31)) * moveSpeed#
ENDFUNCTION
If you're wondering how the movement line works, just follow it through. When you check if a key is pressed, you'll get either a 1 (pressed) or a 0 (depressed). If you subtract the W key's state from the S key's state, you'll get either -1 (If the S key is pressed and the W key isnt), 1 (If the W key is pressed and the S key isnt), or 0 (if no keys are pressed).
You also know that the MOVE CAMERA command accepts a positive or negative value, positive moving the camera forward, and negative moving the camera backward.
Putting that together, if we move our camera by a value of WKey - SKey, it'll move forward at 1 unit/loop when the W key is pressed, and backward at -1 units/loop when the S key is pressed. Similarily, it wont move when neither key is pressed, or when both keys are pressed.
Finally, we multiply the value returned from that little formula (WKey - SKey) by the moveSpeed# variable. So if you want the camera to move at 0.5 units/loop, you set moveSpeed# to 0.5.
Here's a test program to experiment with:
`Main settings
SYNC ON:SYNC RATE 0:AUTOCAM OFF:HIDE MOUSE
`Make a matrix, purely for visual effects, not needed
MAKE MATRIX 1,1000,1000,10,10
POSITION MATRIX 1,-500,0,-500
`Start the main loop
DO
`Handle camera movement using our function
handleCamera(0,0.5,0.1)
`Refresh the screen
SYNC
`Repeat
LOOP
`Declare the handleCamera function (always declare functions after your program's main loop).
FUNCTION handleCamera(cam, moveSpeed#, lookSensitivity#)
ROTATE CAMERA CAMERA ANGLE X(cam) + (MOUSEMOVEY() * lookSensitivity#), CAMERA ANGLE Y(cam) + (MOUSEMOVEX() * lookSensitivity#), 0
MOVE CAMERA cam,(KEYSTATE(17)-KEYSTATE(31)) * moveSpeed#
ENDFUNCTION
Hope that helps clear things up a bit,
- RUC'