Hello all.
I've been experimenting with some mouse movement for my game (
being made on a live stream!) and a few things came to mind.
First off, there's the problem of the mouse reaching the end of the screen. If the game uses the mouse delta to do some movement, for example, the mouse gets stuck on that side.
I did some research and apparently "wrapping" the mouse to the other side seemed like a nice solution. But I think it may give wrong results in this case:
----------------------|
p1------p2-------p3-| Edge
----------------------|
In this case, we could wrap the mouse back to the left but that frame's delta (betwen p3 and "p4", assuming a constant velocity) will be smaller that what the player actually moved, because "p4" it got clamped in the right-most mouse region.
Another solution that came to mind was to "stick" the mouse back to the center every frame, so that we only get the mouse delta and set its position back to where the player is free to move it.
That sounds nice but I'm not sure how robust is this (in the case of alt-tabbing a lot, for instance), and a bug would render the mouse useless.
So I guess my question is: how is this actually done in most games? Is sticking-the-mouse-to-the-center solution good?
Thanks, everybody!
Dan Zaidan