I am developing a simple 2d game where a user has to point a gun at different objects and shoot them. When a user moves his mouse, the crosshair's position always stays the same, but the environment (all other objects) move, creating an effect of a crosshair moving. The problem is, when a cursor leaves the div (where all of the above happens), everything stops moving.
So, the question is: how can I make the cursor never leave the div (with a game) unless the game is paused?
Example of what I expect: link. In this game, when a user's playing, their cursor is always inside a game screen, but when he's in the menu or the game is paused, their cursor can leave a game screen.