I'm in the process of developing a game where an image follows the cursor. I want to prevent players from cheating by moving the cursor outside the designated area and then reaching the finish line. Currently, the image moves wherever my cursor goes. Any suggestions on how to address this?
Here is the code snippet:
$(document).mousemove(function(e){
$("#image").css({left:e.pageX, top:e.pageY});
});
* {cursor: none;}
#image{
position:absolute;
width:25px;
height:auto;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
<img id="image" src="http://static.micheljansen.org/uploads/mac-osx-arrow-cursor.png"/>
Check out the JsFiddle demo here: https://jsfiddle.net/3x7cgLdr/