Quick answer: Pygame tilemap showing 1-pixel gaps between tiles when scrolling? Snap the camera position to integers before drawing, and disable subpixel scaling.
A tiled background develops vertical seams as the camera scrolls. The camera offset is fractional and tile draws end up off-pixel.
Round the Camera
cam_x, cam_y = int(cam_x), int(cam_y)Pygame doesn’t sub-pixel sample. A 0.5 camera offset rounds to 0 or 1 per tile, exposing gaps.
Avoid Scaled Surfaces
Drawing tiles to a scaled surface (e.g. transform.scale) interpolates edges. Pre-scale tiles once with nearest neighbor via pygame.transform.scale at integer ratios.
Bleeding Texture Atlas
If tiles are from an atlas, pad each tile with a 1-pixel border copy of its edge color. Eliminates atlas-edge sampling artifacts at any zoom.
Verifying
Scroll smoothly through the map: no flickering seams between tiles. Zoom in 2x: same clean look.
“Tile gaps are fractional camera math. Round, avoid subpixel scale, and pad atlas tiles.”
If you must support fractional camera positions, render the tile layer to a surface at integer offset and translate the surface fractionally — gives smooth motion without seams.