convert mouse position to grid coordinate