I am making a checkers game and currently the player can move the piece to any part of the board, how can I stop this?
if(Greenfoot.mouseDragged(this)){
MouseInfo mouse=Greenfoot.getMouseInfo();
if(!drag){
drag=true;
rx=getX()-mouse.getX();
ry=getY()-mouse.getY();
hitTheEdge();
} else {
setLocation(mouse.getX()+rx,mouse.getY()+ry);
hitTheEdge();
}
}
}
if(Greenfoot.mouseDragEnded(this)){
drag=false;
}