Python: How to make drawn elements snap to grid in pygame
You have to align the position to the grids size. Use the floor division operator (//) to divide the coordinates by the size of a cell and compute the integral index in the grid: x, y = pygame.mouse.get_pos() ix = x // sizebtwn iy = y // sizebtwn Multiply the result by the size of … Read more