Hopson97 / open-builder

Open "Minecraft-like" game with multiplayer support and Lua scripting support for the both client and server
https://github.com/Hopson97/open-builder/projects/3
GNU General Public License v3.0
700 stars 80 forks source link

Mouse behaviour when unlocking mouse #28

Closed janvanbouwel closed 4 years ago

janvanbouwel commented 4 years ago

Originally, after unlocking mouse, the mouse gets teleported back, even when it is not in the window.

After #25 this still happens but only if the y-position is below the top border of the window. The fps camera also moves to the side because the last mouse position doesn't update

Reproduce: press L key, move mouse off window, press L key again. If mouse is above top border, nothing happens, when mouse moves down, it gets teleported onto the screen and the camera jerks.

This is a fix for this.

janvanbouwel commented 4 years ago

it would make sense to put isMouseInWindow in the Window class, however handleInput is passed an SFML Window, so I have now put the function as a static funtion of the custom Window class