Understanding Chunks
GRPG’s world is divided into chunks - fixed-size 16x16 tile grids that are loaded and unloaded as players move through the world.Each chunk is identified by X/Y coordinates. For example, chunk (0, 0) contains world tiles (0-15, 0-15), and chunk (1, 0) contains tiles (16-31, 0-15).
Chunk Structure
Fromdata-go/grpgmap/grpgmap.go:7:
- 256 tiles - The ground layer (grass, stone, water, etc.)
- 256 object slots - Interactive objects, NPCs, decorations (can be empty)
Getting Started with the Map Editor
Launch the Editor
Build and run the map editor from the source:The editor window opens with three panels:
- Editor - 16x16 grid for placing tiles/objects
- Controls - Buttons for loading assets and saving
- Selector - Tabbed interface for choosing tiles and objects
Load Your Assets
Before you can edit, load your game assets:
- Click Load Textures → Select your
.grpgtexfile - Click Load Tiles → Select your
.grpgtilefile - Click Load Objs → Select your
.grpgobjfile
Load textures first, as tiles and objects reference texture IDs.
Creating a Map
Place Ground Tiles
- Switch to the Tiles tab in the Selector panel
- Click on a tile type (e.g., “grass”)
- Click on the grid to place tiles
- Fill the entire 16x16 grid
Place Objects
- Switch to the Objs tab in the Selector panel
- Click on an object type
- Click on the grid to place objects
Loading Existing Maps
To edit an existing map:Load Map File
- Click Load Map
- Select a
.grpgmapfile
- Chunk coordinates (auto-filled in the controls)
- All tiles and their positions
- All objects and their positions
Map File Format
GRPG map files (.grpgmap) use a binary format defined in data-go/grpgmap/:
- Header (12 bytes) - Magic bytes + chunk coordinates
- Tiles (512 bytes) - 256 tiles × 2 bytes each (uint16 tile ID)
- Objects (512 bytes) - 256 objects × 2 bytes each (uint16 object ID, 0 = empty)
Editor Controls Reference
Control Panel Buttons
| Button | Description |
|---|---|
| Load Textures | Load .grpgtex file with texture data |
| Load Objs | Load .grpgobj file with object definitions |
| Load Tiles | Load .grpgtile file with tile definitions |
| Save Map | Export current chunk to .grpgmap file |
| Load Map | Import existing .grpgmap file for editing |
| Set all empty tiles to currently selected | Fill all unfilled tiles with selected tile |
| Clear Grid | Reset all tiles and objects to empty |
| Enable Eraser | Switch to eraser mode for removing objects |
Keyboard Shortcuts
Currently, the editor uses mouse-only controls. Click-based workflow:- Select tile/object from the selector panel
- Click on grid cells to place
- Use eraser mode to remove objects
Advanced Techniques
Creating Multi-Chunk Worlds
Create Each Chunk
For each chunk:
- Set the chunk coordinates
- Design the chunk (consider how it connects to neighbors)
- Save as
chunk_X_Y.grpgmap
Patterns and Templates
Create reusable chunk templates:- Town Template - Paths, buildings, NPCs
- Forest Template - Trees, berry bushes, natural objects
- Dungeon Template - Stone walls, doors, enemies
Object Density Guidelines
For optimal performance and gameplay:- Towns: 20-40 objects per chunk (buildings, NPCs, decorations)
- Wilderness: 5-15 objects per chunk (trees, resource nodes)
- Dungeons: 30-50 objects per chunk (walls, enemies, loot)
Map Editor Source Reference
The map editor is built with giu, a Go immediate-mode GUI library:map-editor/main.go:16- Entry point and UI loopmap-editor/grid.go- Grid rendering and interactionmap-editor/selector.go- Tile/object selection panelmap-editor/map.go:12- Save/load functionalitymap-editor/controls.go- Control panel buttons
Customizing the Editor
The editor source is designed to be modifiable. Common customizations: Change grid size (requires changing chunk format):map-editor/grid.go
map-editor/main.go:17
map-editor/map.go:12
Troubleshooting
Can't save map: 'Both Chunk X & Chunk Y must be set'
Can't save map: 'Both Chunk X & Chunk Y must be set'
Enter numeric values for both Chunk X and Chunk Y in the controls panel. Both fields default to -1 and must be set to valid coordinates (can be 0 or positive).
Can't save map: 'All tiles must be filled in'
Can't save map: 'All tiles must be filled in'
The editor found empty tiles in your grid. Either:
- Manually place tiles in all empty cells
- Select a tile and click Set all empty tiles to currently selected
Tiles/Objects don't show textures
Tiles/Objects don't show textures
Load order matters:
- Load Textures first (
.grpgtex) - Load Tiles (
.grpgtile) - Load Objects (
.grpgobj)
Loaded map has wrong chunk coordinates
Loaded map has wrong chunk coordinates
The map file stores chunk coordinates in its header. When you load a map, the editor automatically populates the Chunk X/Y fields from the file.To move a chunk to new coordinates:
- Load the map
- Change Chunk X/Y values
- Save as a new file
Objects disappear when loading map
Objects disappear when loading map
Ensure the same object file (
.grpgobj) is loaded when editing. If object IDs don’t match between your current object file and the saved map, objects may not render correctly.Map Loading in the Server
Maps you create are loaded by the server at runtime. The server:- Reads the chunk coordinates from the header
- Loads tiles and objects into the game world
- Positions the chunk at the correct world coordinates
- Handles chunk loading/unloading based on player positions
data-go/grpgmap/grpgmap.go for the loading implementation.
Next Steps
Creating Content
Add interactive behavior to objects on your map
Custom Objects
Create new object types to place on your maps