Original Post
I am making a SimCity type of game. I am trying to make a 'snap to grid' function in the game. I have the mouse screen position and I would like to aproximate it to the nearest grid line position. I have a grid line every five pixels so for instance if the mouse position will be 432 the position has to be approximated to 430, for 548 the approximated position should be 550.