FPS movement question

Started by
1 comment, last by meeshoo 12 years, 2 months ago
Hey guys

So basically, how do you move the camera??
I used to just basically use WM_LBUTTONDOWN to invoke SetCapture() and save the current mouse position, and then, in WM_MOUSEMOVE, i just capture the new mouse position and get the difference as dx and dy for the movement.

But i just want to move the camera without the need to press LMB every time(like in a real FPS shooter).

So what is wrong with my current code??



case WM_CREATE:
SetCapture(mMainWnd);
return 0;


case WM_DESTROY:
PostQuitMessage(0);
ReleaseCapture();
return 0;


case WM_MOUSEMOVE:

mOldMousePos = mMousePos;
mMousePos.x = (int)LOWORD(lparam);
mMousePos.y = (int)HIWORD(lparam);

mCameraDx = mMousePos.x - mOldMousePos.x;
mCameraDy = mMousePos.y - mOldMousePos.y;

return 0;


mMousePos is initially initialized as (0,0) and both it and mOldMousePos are ::POINT members.

my current problem with this code is that it is moving SO SLOWLY every two seconds or so. It is not in real-time
Advertisement
Im not an expert with Windows, but that code looks fine. How are you handling your Messages? (DispatchMessage(),etc) Why not use RawInput?
You should dabble into other input methods like DirectInput. What DI does is that t doesn't use the windows mouse input, which is too slow, but it works directly with your mouse driver. Although a bit old, these might help http://www.directxtutorial.com/tutorial9/e-directinput/dx9E.aspx

This topic is closed to new replies.

Advertisement