Tiled Map Editor Integration¶
This guide covers everything you need to know about using Tiled Map Editor with Pedre. Tiled is a powerful, free map editor that lets you design your game levels visually.
Table of Contents¶
- Installation
- Map Setup
- Required Layers
- Map Configuration
- Player Character Setup
- Working with NPCs
- Portals and Transitions
- Waypoints
- Interactive Objects
- Custom Properties
Installation¶
- Download Tiled from mapeditor.org
- Install following the instructions for your platform
- Launch Tiled to verify installation
Map Setup¶
Creating a New Map¶
-
File → New → New Map
-
Map Settings:
- Orientation: Orthogonal
- Tile layer format: CSV (recommended)
- Tile render order: Right Down
- Map size: 25×20 tiles (or whatever size you need)
- Tile size: 32×32 pixels (must match your tileset)
-
Click Save As and save to
assets/maps/your_map.tmx
Adding a Tileset¶
-
Map → New Tileset
-
Tileset Settings:
- Name: Something descriptive (e.g., "terrain", "buildings")
- Type: Based on Tileset Image
- Image: Browse to your tileset PNG file
- Tile width: 32 pixels
- Tile height: 32 pixels
- Margin/Spacing: Set if your tileset has borders
-
Click Save As and save to
assets/tilesets/your_tileset.tsx
Recommended Free Tilesets¶
- Kenny.nl - Various game assets
- OpenGameArt.org - Community-created tilesets
- itch.io - Free and paid tilesets
Required Layers¶
The framework expects specific layer names. Create these layers in order:
Tile Layers¶
Floor Layer¶
This is where you paint your ground terrain:
- Grass, dirt, stone floors
- Roads, paths
- Water (if non-solid)
- Decorative ground elements
Walls Layer¶
Paint your solid obstacles here:
- Building walls
- Trees, rocks
- Fences
- Any tile that should block player movement
The framework automatically treats all tiles in this layer as solid collision objects.
Objects Layer¶
Use this for smaller collidable objects like furniture, rocks, or signposts.
Buildings Layer¶
Use this for larger structures.
Collision Layer (Optional)¶
Use this for:
- Invisible walls
- Collision boundaries
- Areas where you don't want a visual tile but need collision
Tip: Set this layer's opacity to 0.5 in Tiled so you can see it while editing.
Object Layers¶
NPCs Layer¶
See Working with NPCs for details.
Portals Layer¶
See Portals and Transitions for details.
Waypoints Layer¶
See Waypoints for details.
Interactive Layer (Optional)¶
See Interactive Objects for details.
Layer Order¶
The order matters for rendering! From bottom to top:
Floor (bottom - drawn first)
Walls
Objects
Buildings
Collision
NPCs
Interactive
Portals
Waypoints (top - drawn last)
Map Configuration¶
Per-map settings — background music, camera target, and camera movement style — are defined in assets/data/content/maps.json, not as Tiled map properties.
Each entry is keyed by the scene name (TMX filename without extension, lowercased). All fields are optional; only add what you want to override from the defaults.
{
"village": {
"music": "peaceful_village.ogg",
"camera_follow": "player",
"camera_smooth": true
},
"cutscene_tower": {
"camera_follow": "npc:wizard"
},
"puzzle_room": {
"camera_follow": "none"
}
}
See Maps Content Reference for the full field reference, camera follow modes, and more examples.
Player Character Setup¶
The player character is automatically created and managed by the framework, but you can configure its initial position and appearance.
Player Spawn Position¶
The framework determines the player's spawn position based on the player content registry:
- Portal Waypoint - Default behaviour; player spawns at the waypoint named by the portal's
spawn_waypointaction parameter - Player Object Position - Used on maps listed in
spawn_at_positioninplayers.json
Player Object Setup:
The Player object must be placed as a Point object in the "Player" object layer and positioned where you want the player to spawn by default.
Creating the Player Object:
- Select Player object layer (create if needed)
- Click Insert Point (or press I)
- Click where you want the player to spawn
Controlling Spawn Behaviour (Optional):
Spawn behaviour is configured in players.json, not via Tiled properties. Add the map name to spawn_at_position to make the player spawn at the Player object position on that map instead of at a portal waypoint:
If spawn_at_position is absent or does not include the current map, the player always spawns at the portal waypoint.
Portal Waypoints¶
When players transition through portals, they spawn at the target waypoint specified in the portal's spawn_waypoint property.
- Select Waypoints object layer
- Click Insert Point (or press I)
- Click where you want the portal target to be
- In Properties panel, set
nameto match the portal'sspawn_waypoint
Example Portal Setup:
In village.tmx portal:
In forest.tmx waypoints:
Player Sprite Configuration¶
The player sprite is driven entirely by the content registry. Animation states, sprite sheet path, and frame layout are defined in sprites.json. The Tiled Player object only provides the spawn position — no properties are read from it.
How it works:
- The
PlayerPluginreads the Player object from Tiled to get the spawn position. - It looks up the player definition in the
playerscontent registry (key"player"inplayers.json). - The player definition's
sprite_idfield references an entry insprites.json. - It creates an
AnimatedSpritefrom that definition.
players.json fields:
| Field | Type | Required | Description |
|---|---|---|---|
sprite_id |
string | Yes | ID of the sprite definition in sprites.json |
spawn_at_position |
list of strings | No | Map names where player spawns at the Tiled object position |
Example Player Object (Tiled — position only):
Player Object Layer:
- Point at (640, 480)
(no properties needed — sprite and spawn config live in players.json)
Example assets/data/content/players.json:
Corresponding sprites.json entry:
{
"princess": {
"sprite_sheet": "images/characters/princess.png",
"frame_width": 64,
"frame_height": 64,
"states": {
"idle": {
"directional": true,
"loop": true,
"priority": 0,
"directions": {
"down": {"frames": 4, "row": 0},
"up": {"frames": 4, "row": 1},
"right": {"frames": 4, "row": 2}
}
},
"walk": {
"directional": true,
"loop": true,
"priority": 1,
"directions": {
"down": {"frames": 6, "row": 3},
"up": {"frames": 6, "row": 4},
"right": {"frames": 6, "row": 5}
}
}
}
}
}
See Sprites Content Reference and Sprites API for details on defining sprite states.
Player Movement¶
The player is controlled via keyboard input:
- Arrow Keys - Move in 8 directions
- WASD - Alternative movement keys
- SPACE - Interact with NPCs and objects nearby
Movement Configuration:
Player movement and interaction speeds are controlled by game settings in your settings.py file. See Configuration Guide for all available player and interaction settings including:
PLAYER_MOVEMENT_SPEED- Player movement speedINTERACTION_PLUGIN_DISTANCE- Object interaction rangeNPC_INTERACTION_DISTANCE- NPC interaction rangePORTAL_INTERACTION_DISTANCE- Portal activation range
Player Collision¶
The player automatically collides with:
- Tiles in the Walls layer
- Tiles in the Collision layer
- Tiles in the Objects layer
- Tiles in the Buildings layer
- NPCs (unless they're removed from collision with scripts)
The physics engine uses arcade.PhysicsEngineSimple for player-wall collision detection.
Example: Complete Player Setup¶
In Tiled (village.tmx):
Player Object Layer:
- Point at (640, 480)
(no properties needed — sprite and spawn config live in players.json)
In assets/data/content/players.json:
spawn_at_position: ["village"] means the player spawns at the Tiled object position (640, 480) when loading village. On any other map (e.g. forest) the player spawns at the portal's target waypoint.
In assets/data/content/sprites.json:
{
"princess": {
"sprite_sheet": "images/characters/princess.png",
"frame_width": 64,
"frame_height": 64,
"states": {
"idle": {
"directional": true, "loop": true, "priority": 0,
"directions": {
"down": {"frames": 4, "row": 0},
"up": {"frames": 4, "row": 1},
"right":{"frames": 4, "row": 2}
}
},
"walk": {
"directional": true, "loop": true, "priority": 1,
"directions": {
"down": {"frames": 6, "row": 3},
"up": {"frames": 6, "row": 4},
"right":{"frames": 6, "row": 5}
}
}
}
}
}
For Portal-Only Entry (forest.tmx):
Player Object Layer:
- Point at (400, 300)
(position used as fallback only; forest is not in spawn_at_position)
Waypoints Layer:
- Point named "from_village" at (100, 200)
In Code (Game initialization):
settings.py:
# Configure your game
WINDOW_TITLE="My RPG"
SCREEN_WIDTH=1920
SCREEN_HEIGHT=1080
INITIAL_MAP="village.tmx"
main.py:
This will create a window with your custom settings and start the game.
- Spawn at Player object position (640, 480) on
village(listed inspawn_at_position) - Use the princess sprite sheet
- Be able to move with arrow keys
- Collide with walls, objects, and NPCs
- Interact with objects via SPACE key
When entering via portal: Player spawns at the portal's target waypoint (unless the map is listed in spawn_at_position).
Working with NPCs¶
NPCs are placed as Point Objects in the NPCs object layer. Like the player, NPC appearance is driven by the content registry — sprite sheets, animation states, scale, and visibility are defined in npcs.json and sprites.json.
How NPC Loading Works¶
- The
NPCPluginreads each Point object from theNPCslayer to get the name and spawn position. - It looks up the NPC definition in
npcs.jsonby the object'snameproperty. - The NPC definition references a
sprite_idpointing to an entry insprites.json. - An
AnimatedSpriteis created from the sprite definition, withscale,tile_size, andinitially_hiddentaken from the NPC definition.
Adding an NPC¶
- Select the NPCs object layer
- Click Insert Point (or press I)
- Click where you want the NPC to spawn
- In the Properties panel, set the
nameproperty
Tiled Object Properties¶
| Property | Type | Required | Description |
|---|---|---|---|
name |
string | Yes | NPC identifier — must match a key in npcs.json (case-insensitive) |
All other appearance settings (tile_size, scale, initially_hidden) belong in npcs.json.
NPC Content Registry Definitions¶
assets/data/content/npcs.json:
{
"merchant": {
"sprite_id": "merchant_sprite",
"scale": 1.0,
"tile_size": 64
},
"wizard": {
"sprite_id": "wizard_sprite",
"initially_hidden": true
}
}
assets/data/content/sprites.json:
{
"merchant_sprite": {
"sprite_sheet": "images/characters/merchant.png",
"frame_width": 64,
"frame_height": 64,
"states": {
"idle": {
"directional": true, "loop": true, "priority": 0,
"directions": {
"down": {"frames": 4, "row": 0},
"up": {"frames": 4, "row": 1},
"right":{"frames": 4, "row": 2}
}
},
"walk": {
"directional": true, "loop": true, "priority": 1,
"directions": {
"down": {"frames": 6, "row": 3},
"up": {"frames": 6, "row": 4},
"right":{"frames": 6, "row": 5}
}
}
}
},
"wizard_sprite": {
"sprite_sheet": "images/characters/wizard.png",
"frame_width": 64,
"frame_height": 64,
"states": {
"idle": {
"directional": false, "loop": true, "priority": 0,
"frames": 4, "row": 0
},
"appear": {
"directional": false, "loop": false, "priority": 5,
"on_complete": "idle", "frames": 9, "row": 1
},
"disappear": {
"directional": false, "loop": false, "priority": 5,
"on_complete": "hide", "auto_from": "appear"
}
}
}
}
See Sprites Content Reference and Sprites API for the full sprite definition format, including auto_from states and directional auto-flip.
Example NPC Setup in Tiled¶
Minimal — all appearance config is in the registry:
Multiple NPCs:
NPCs Layer:
- Point at (320, 240) → name: "merchant"
- Point at (640, 480) → name: "guard"
- Point at (800, 360) → name: "elder"
Each NPC needs:
- A unique
nameproperty matching a key innpcs.json - A corresponding entry in
npcs.jsonreferencing asprite_idinsprites.json - Optional: Dialog entries in
assets/data/content/dialogs/{scene_name}.jsonif the NPC should be interactive
Portals and Transitions¶
Portals are Rectangle Objects that trigger map transitions when the player enters them. The portal plugin uses an event-driven architecture where portal behavior is defined in JSON scripts.
Creating a Portal¶
- Select the Portals object layer
- Click Insert Rectangle (or press R)
- Draw a rectangle where the portal zone should be
- Set the portal's
nameproperty
Portal Properties¶
| Property | Type | Required | Description | Example |
|---|---|---|---|---|
name |
string | Yes | Unique portal identifier (used in script triggers) | "to_forest" |
Portal behavior (destination, conditions, cutscenes) is defined in script files, not Tiled properties.
Example Portal Setup¶
In village.tmx:
In forest.tmx:
In scripts JSON:
{
"to_forest_portal": {
"trigger": {"event": "portal_entered", "portal": "to_forest"},
"actions": [
{"name": "change_scene", "target_map": "forest.tmx", "spawn_waypoint": "from_village"}
]
}
}
Portal Scripts¶
Portal transitions are handled through the script plugin using the portal_entered event and change_scene action.
Simple Portal:
{
"forest_portal": {
"trigger": {"event": "portal_entered", "portal": "forest_entrance"},
"actions": [
{"name": "change_scene", "target_map": "Forest.tmx", "spawn_waypoint": "entrance"}
]
}
}
Conditional Portal:
{
"tower_gate_open": {
"trigger": {"event": "portal_entered", "portal": "tower_gate"},
"conditions": [{"name": "npc_dialog_level", "npc": "guard", "gte": 2}],
"actions": [
{"name": "change_scene", "target_map": "Tower.tmx", "spawn_waypoint": "entrance"}
]
},
"tower_gate_locked": {
"trigger": {"event": "portal_entered", "portal": "tower_gate"},
"conditions": [{"name": "npc_dialog_level", "npc": "guard", "lt": 2}],
"actions": [
{"name": "dialog", "speaker": "Narrator", "text": ["The gate is locked..."]}
]
}
}
Portal with Cutscene:
{
"dungeon_first_entry": {
"trigger": {"event": "portal_entered", "portal": "dungeon_portal"},
"run_once": true,
"actions": [
{"name": "dialog", "speaker": "Narrator", "text": ["A cold wind blows..."]},
{"name": "wait_for_dialog_close"},
{"name": "change_scene", "target_map": "Dungeon.tmx", "spawn_waypoint": "entrance"}
]
},
"dungeon_return": {
"trigger": {"event": "portal_entered", "portal": "dungeon_portal"},
"conditions": [{"name": "script_completed", "script": "dungeon_first_entry"}],
"actions": [
{"name": "change_scene", "target_map": "Dungeon.tmx", "spawn_waypoint": "entrance"}
]
}
}
See Scripting Events and Scripting Actions for more details.
Waypoints¶
Waypoints are Point Objects that define named positions on the map.
Creating a Waypoint¶
- Select the Waypoints object layer
- Click Insert Point (or press I)
- Click where you want the waypoint
- Set the
nameproperty
Waypoint Uses¶
| Use Case | Description |
|---|---|
| Portal destinations | Target location for map transitions (used with portal spawn_waypoint property) |
| NPC movement | Destinations for pathfinding scripts |
Note: Waypoints are simple named locations stored as Point objects. They only need a name property. The framework stores their pixel coordinates in a dictionary for lookup by name.
Example Waypoint Setup¶
Layer: Waypoints
Points:
- name: "from_village" at (100, 100)
- name: "from_forest" at (750, 50)
- name: "merchant_home" at (200, 450)
- name: "well" at (600, 350)
- name: "town_center" at (500, 400)
Using Waypoints in Scripts¶
Reference waypoints by name in your scripts:
The NPC will use A* pathfinding to navigate to the waypoint, avoiding walls.
Interactive Objects¶
Interactive objects are shapes (rectangles, polygons, points) that trigger actions when the player presses SPACE nearby.
Creating Interactive Objects¶
- Select the Interactive object layer
- Insert any shape type:
- Rectangle - Area-based interactions (chests, doors)
- Point - Single-point interactions (signs, items)
- Polygon - Complex shape interactions
- Set the object's properties
Interactive Object Properties¶
| Property | Type | Required | Description | Example |
|---|---|---|---|---|
name |
string | Yes | Unique identifier | "treasure_chest" |
Custom Properties¶
You can add any custom properties to objects and reference them in scripts.
Adding Custom Properties¶
- Select an object
- In Properties panel, click the + button
- Choose property type:
- bool - true/false
- int - Integer numbers
- float - Decimal numbers
- string - Text
- color - Color value
- file - File path
Resources¶
Next Steps:
- Scripting Guide - Learn about event-driven actions
- Plugins Reference - Individual plugin documentation
- API Reference - API reference