im just heading to bed so I wont be giving my usual in-depth code examples this time (sorry! if you still have trouble tomorrow then I will after work
) but the functions you want to slide (strafe) the camera are dbNewXValue() and dbNewZValue().
These two commands (and there is one for Y too but you dont need that in this case) calculate a new position along the x and z values based off the current value, an angle given and a distance value saying how much to move.
In short it can be read as: give me the position I would be in if I move from
this position in the direction of
this angle and I go
this far.
The same can be acheived using sin/cos math but these functions make it easier. In the case of your camera you want to slide left and right. If you think about it thats just moving along a line 90 degrees from the current angle of the camera, so we can just say something like:
float fSideAngleLeft = dbWrapValue(dbCameraAngleY(0) - 90.0f);
float fSideAngleRight = dbWrapValue(dbCameraAngleY(0) + 90.0f);
float fDistanceToMove = 1.5f;
float fNewX = dbCameraPositionX(0);
float fNewZ = dbCameraPositionZ(0);
if (user pressing left key) {
fNewX = dbNewXValue(dbCameraPositionX(0), fSideAngleLeft, fDistanceToMove);
fNewZ = dbNewZValue(dbCameraPositionZ(0), fSideAngleLeft, fDistanceToMove);
} else {
if (user pressing right key) {
fNewX = dbNewXValue(dbCameraPositionX(0), fSideAngleRight, fDistanceToMove);
fNewZ = dbNewZValue(dbCameraPositionZ(0), fSideAngleRight, fDistanceToMove);
}
}
dbPositionCamera(0, fNewX, dbCameraPositionY(0), fNewZ);
There, if I havnt made some sleepy mistake that should work (sigh, guess I wrote the code anyway huh?
). dbWrapValue() just keeps a value between 0 and 360 and wraps it around so you always get a "real angle" that makes sense. I store off the current X and Z positions of the camera in the new position variables first incase the user presses no keys (then it will just position the camera at its current location with no problems).
the left and right angles are just the current rotation of the camera plus and minus 90 degrees as nessiary. The rest I think I already explained
Hope that helps!