In my game you control the player with the mouse. You can only move left and right and shoot.
So I have code like this:
Player.y = 400
Every tick:
Player.x = mouse.x
But what a lot of my play testers do in their enthusiasm is move the mouse to far, and thus get out of the layout. When this happens you can no longer shoot or move, witch most of the time lead to death.
I wanted to fix this by adding code like:
Every tick:
Mouse.y = 400
if mouse.x < 0 mouse.x = 0
if mouse.x > 640 mouse.x = 640
But you can't set the mouse coordinates.
Is there an other way to make sure you don't click outside of the layout?