Yes, but there isn't enough information in your question to really help. Generally you snap to a grid, which is what I think you are asking about, with something like x = x div grid_size;
, but that isn't the only way, and some of it depends on the rest of your code.