Issues with comparing position values and limiting movement[SOLVED]

I am making a chess-like game and I am stuck with a problem
My goal is to limit the pieces movement to 1 square every direction
There are 64 pixels between squares so I did this

However instead of doing what I wanted, it did not limit any movement on the y axis and limited all of the movement on the x axis

I am also printing out the values of oldx ,oldy current x, current y, current x-64 and current y+64 and those values are printed as expected

What is the problem here and how can I solve this? If it is a bug is there any other methods I could use to limit the pieces movement?


EDIT:I realized I am comparing the wrong objects position. I cant believe I spent 3 hours trying to fix this

1 Like