Are you actually changing the X and Y variables? Those are going to control the sprite's location the way you have this programmed.