Lines 10,11,12, and 13 seem tlike they arent doing what theyre supposed to do, since you change X and Y while checking the positions Maybe if 11,12, and 13 were elseifs then it would function right