On this page
How to use it#
- Set the map's columns, rows and tile size, then press Resize map. Existing tiles are kept where they fit.
- Pick a tile from the palette and paint by clicking or dragging. Right-click erases; fill floods an area.
- To use your own art, Import tileset image: it's cut into squares of the tile size, left to right and top to bottom.
- Export the map as JSON or CSV, the tiles as Tileset PNG, and copy the Pygame loader.
- Open JSON or CSV reloads a saved map to keep editing.
With the map focused, the arrow keys move a cursor and Space or Enter paints. The status bar shows the tile and pixel position under the pointer. Your map is saved in this browser automatically.
File formats#
CSV: one row of the map per line, tile IDs separated by commas. 0 means empty; the first tile in the tileset is 1.
0,0,0,0,0
0,4,4,0,0
3,3,3,3,3
2,2,2,2,2JSON: the same grid plus metadata:
{ "format": "pygame.net-tilemap", "version": 1, "tile_size": 32,
"columns": 5, "rows": 4, "tileset": "tileset.png", "empty": 0,
"data": [[0,0,0,0,0], [0,4,4,0,0], [3,3,3,3,3], [2,2,2,2,2]] }Using the map in Pygame#
The copied loader provides load_tileset(), load_map(), draw_map() (with camera offsets) and solid_rects() for collisions. A minimal game loop using it:
tiles = load_tileset("tileset.png")
level = load_map("map.csv")
walls = solid_rects(level, solid_ids={2, 3, 4})
while running:
...
screen.fill("skyblue")
draw_map(screen, level, tiles, camera_x, camera_y)The tile maps tutorial explains pre-rendering and cameras, and the platformer tutorial shows collisions with tiles.
Built-in tiles#
The eight built-in tiles (grass, dirt, ground top, stone, water, sand, brick and coin) are drawn by the editor, so you can prototype immediately. Tileset PNG exports them for use in your game; they are free to use.