Skip to content

Commit

Permalink
Handle Tiled worlds (#63)
Browse files Browse the repository at this point in the history
Co-authored-by: JtotheThree <[email protected]>
  • Loading branch information
adrien-bon and JtotheThree authored Jan 6, 2025
1 parent 0bd8b01 commit 6324e40
Show file tree
Hide file tree
Showing 51 changed files with 1,687 additions and 241 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

## [unreleased]

### Features

- Add Tiled .world file support (#55)

### Changed

- `TiledPhysicsBackend` now requires to implement the `Clone` trait
- Switched some map logs from `info!()` to `debug!()`

## v0.5.1

### Features
Expand Down
7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ user_properties = ["dep:serde", "dep:serde_json"]
# Main dependencies
bevy = { version = "0.15", default-features = false }
bevy_ecs_tilemap = { version = "0.15", default-features = false }
tiled = "0.13"
tiled = { git = "https://github.com/mapeditor/rs-tiled.git", rev = "c434e1be8904917bacc1286c5334b721f1f6deef", features = ["world"] }

# Utilities
futures-lite = "2.5"
Expand Down Expand Up @@ -137,4 +137,7 @@ required-features = ["avian_debug"]

[[example]]
name = "properties_basic"
required-features = ["user_properties"]
required-features = ["user_properties"]

[[example]]
name = "world"
4 changes: 4 additions & 0 deletions assets/test.world
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"onlyShowAdjacentMaps": false,
"type": "world"
}
181 changes: 181 additions & 0 deletions assets/world/world.world
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
{
"maps": [
{
"fileName": "world_map001.tmx",
"height": 512,
"width": 512,
"x": 0,
"y": 0
},
{
"fileName": "world_map002.tmx",
"height": 512,
"width": 512,
"x": 512,
"y": 0
},
{
"fileName": "world_map003.tmx",
"height": 512,
"width": 512,
"x": 1024,
"y": 0
},
{
"fileName": "world_map004.tmx",
"height": 512,
"width": 512,
"x": 1536,
"y": 0
},
{
"fileName": "world_map005.tmx",
"height": 512,
"width": 512,
"x": 2048,
"y": 0
},
{
"fileName": "world_map006.tmx",
"height": 512,
"width": 512,
"x": 0,
"y": 512
},
{
"fileName": "world_map007.tmx",
"height": 512,
"width": 512,
"x": 512,
"y": 512
},
{
"fileName": "world_map008.tmx",
"height": 512,
"width": 512,
"x": 1024,
"y": 512
},
{
"fileName": "world_map009.tmx",
"height": 512,
"width": 512,
"x": 1536,
"y": 512
},
{
"fileName": "world_map010.tmx",
"height": 512,
"width": 512,
"x": 2048,
"y": 512
},
{
"fileName": "world_map011.tmx",
"height": 512,
"width": 512,
"x": 0,
"y": 1024
},
{
"fileName": "world_map012.tmx",
"height": 512,
"width": 512,
"x": 512,
"y": 1024
},
{
"fileName": "world_map013.tmx",
"height": 512,
"width": 512,
"x": 1024,
"y": 1024
},
{
"fileName": "world_map014.tmx",
"height": 512,
"width": 512,
"x": 1536,
"y": 1024
},
{
"fileName": "world_map015.tmx",
"height": 512,
"width": 512,
"x": 2048,
"y": 1024
},
{
"fileName": "world_map016.tmx",
"height": 512,
"width": 512,
"x": 0,
"y": 1536
},
{
"fileName": "world_map017.tmx",
"height": 512,
"width": 512,
"x": 512,
"y": 1536
},
{
"fileName": "world_map018.tmx",
"height": 512,
"width": 512,
"x": 1024,
"y": 1536
},
{
"fileName": "world_map019.tmx",
"height": 512,
"width": 512,
"x": 1536,
"y": 1536
},
{
"fileName": "world_map020.tmx",
"height": 512,
"width": 512,
"x": 2048,
"y": 1536
},
{
"fileName": "world_map021.tmx",
"height": 512,
"width": 512,
"x": 0,
"y": 2048
},
{
"fileName": "world_map022.tmx",
"height": 512,
"width": 512,
"x": 512,
"y": 2048
},
{
"fileName": "world_map023.tmx",
"height": 512,
"width": 512,
"x": 1024,
"y": 2048
},
{
"fileName": "world_map024.tmx",
"height": 512,
"width": 512,
"x": 1536,
"y": 2048
},
{
"fileName": "world_map025.tmx",
"height": 512,
"width": 512,
"x": 2048,
"y": 2048
}
],
"onlyShowAdjacentMaps": false,
"type": "world"
}
24 changes: 24 additions & 0 deletions assets/world/world_map001.tmx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.10" tiledversion="1.11.0" orientation="orthogonal" renderorder="right-down" width="16" height="16" tilewidth="32" tileheight="32" infinite="0" nextlayerid="2" nextobjectid="1">
<tileset firstgid="1" source="../Tileset1.tsx"/>
<layer id="1" name="Tile Layer 1" width="16" height="16">
<data encoding="csv">
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,0,0,4,0,0,0,0,0,0,0,0,4,0,0,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,0,0,0,0,2,2,2,2,2,2,0,0,0,0,2,
2,0,0,0,0,2,0,0,0,0,2,0,0,0,0,2,
2,0,0,0,0,2,0,6,6,0,2,0,0,0,0,2,
2,0,0,0,0,2,0,6,6,0,2,0,0,0,0,2,
2,0,0,0,0,2,0,0,0,0,2,0,0,0,0,2,
2,0,0,0,0,2,0,0,0,0,2,0,0,0,0,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,0,0,4,0,0,0,0,0,0,0,0,4,0,0,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
</data>
</layer>
</map>
24 changes: 24 additions & 0 deletions assets/world/world_map002.tmx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.10" tiledversion="1.11.0" orientation="orthogonal" renderorder="right-down" width="16" height="16" tilewidth="32" tileheight="32" infinite="0" nextlayerid="2" nextobjectid="1">
<tileset firstgid="1" source="../Tileset1.tsx"/>
<layer id="1" name="Tile Layer 1" width="16" height="16">
<data encoding="csv">
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,0,0,0,0,0,4,4,4,4,0,0,0,0,0,2,
2,0,0,0,0,4,4,4,4,4,4,0,0,0,0,2,
2,0,0,4,4,4,4,4,4,4,4,4,4,0,0,2,
2,0,0,4,4,4,4,4,4,4,4,4,4,0,0,2,
2,0,0,4,0,0,0,0,0,0,0,0,4,0,0,2,
2,0,0,4,0,0,0,0,0,0,0,0,4,0,0,2,
2,0,0,4,0,0,0,0,0,0,0,0,4,0,0,2,
2,0,0,4,0,0,0,0,0,0,0,0,4,0,0,2,
2,0,0,4,4,4,4,4,4,4,4,4,4,0,0,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
</data>
</layer>
</map>
24 changes: 24 additions & 0 deletions assets/world/world_map003.tmx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.10" tiledversion="1.11.0" orientation="orthogonal" renderorder="right-down" width="16" height="16" tilewidth="32" tileheight="32" infinite="0" nextlayerid="2" nextobjectid="1">
<tileset firstgid="1" source="../Tileset1.tsx"/>
<layer id="1" name="Tile Layer 1" width="16" height="16">
<data encoding="csv">
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,0,6,0,0,6,0,0,6,0,0,6,0,0,0,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,0,0,0,6,0,0,6,0,0,6,0,0,6,0,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,0,6,0,0,6,0,0,6,0,0,6,0,0,0,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,0,0,0,6,0,0,6,0,0,6,0,0,6,0,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,0,6,0,0,6,0,0,6,0,0,6,0,0,0,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,0,0,0,6,0,0,6,0,0,6,0,0,6,0,2,
2,0,6,0,6,0,6,0,6,0,6,0,6,0,6,2,
2,6,0,6,0,6,0,6,0,6,0,6,0,6,0,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
</data>
</layer>
</map>
24 changes: 24 additions & 0 deletions assets/world/world_map004.tmx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.10" tiledversion="1.11.0" orientation="orthogonal" renderorder="right-down" width="16" height="16" tilewidth="32" tileheight="32" infinite="0" nextlayerid="2" nextobjectid="1">
<tileset firstgid="1" source="../Tileset1.tsx"/>
<layer id="1" name="Tile Layer 1" width="16" height="16">
<data encoding="csv">
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,0,0,0,0,0,0,5,5,5,0,0,0,0,0,2,
2,0,0,0,0,0,0,5,5,5,0,0,0,0,0,2,
2,0,0,0,0,0,0,5,5,5,0,0,0,0,0,2,
2,0,0,0,0,0,0,0,5,0,0,0,0,0,0,2,
2,0,0,0,0,0,5,5,5,5,5,0,0,0,0,2,
2,0,0,0,0,0,0,0,5,0,0,0,0,0,0,2,
2,0,0,0,0,0,0,0,5,0,0,0,0,0,0,2,
2,0,0,0,0,0,0,0,5,0,0,0,0,0,0,2,
2,0,0,0,0,0,0,5,0,5,0,0,0,0,0,2,
2,0,0,0,0,0,5,0,0,0,5,0,0,0,0,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
</data>
</layer>
</map>
24 changes: 24 additions & 0 deletions assets/world/world_map005.tmx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.10" tiledversion="1.11.0" orientation="orthogonal" renderorder="right-down" width="16" height="16" tilewidth="32" tileheight="32" infinite="0" nextlayerid="2" nextobjectid="1">
<tileset firstgid="1" source="../Tileset1.tsx"/>
<layer id="1" name="Tile Layer 1" width="16" height="16">
<data encoding="csv">
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,0,0,0,0,7,7,7,7,7,7,7,7,0,0,2,
2,0,0,0,7,7,7,3,7,7,3,7,7,7,0,2,
2,0,0,0,7,0,0,7,7,7,7,0,0,7,0,2,
2,0,0,0,0,0,0,7,0,0,7,0,0,0,0,2,
2,0,0,0,0,0,0,7,0,0,7,0,0,0,0,2,
2,0,0,0,0,0,0,0,7,0,0,7,0,0,0,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
</data>
</layer>
</map>
24 changes: 24 additions & 0 deletions assets/world/world_map006.tmx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.10" tiledversion="1.11.0" orientation="orthogonal" renderorder="right-down" width="16" height="16" tilewidth="32" tileheight="32" infinite="0" nextlayerid="2" nextobjectid="1">
<tileset firstgid="1" source="../Tileset1.tsx"/>
<layer id="1" name="Tile Layer 1" width="16" height="16">
<data encoding="csv">
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,0,0,0,0,0,0,0,0,2,0,0,0,0,0,2,
2,0,2,0,0,0,0,2,2,0,0,0,0,0,0,2,
2,0,2,2,0,2,2,0,0,0,0,0,0,0,0,2,
2,0,0,0,2,0,0,0,0,0,0,0,0,0,0,2,
2,0,0,0,2,0,0,0,0,0,0,0,0,0,0,2,
2,0,0,0,2,2,2,0,0,0,0,0,0,0,0,2,
2,0,0,0,2,2,0,0,0,0,0,0,0,0,0,2,
2,0,0,0,2,0,0,0,0,0,0,2,0,0,0,2,
2,0,0,0,2,0,0,0,0,0,2,2,0,0,0,2,
2,0,5,0,0,5,0,0,0,2,2,0,0,0,0,2,
2,0,0,5,0,0,5,0,0,0,0,0,0,5,0,2,
2,0,0,0,0,0,0,0,0,0,0,0,5,0,0,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
</data>
</layer>
</map>
24 changes: 24 additions & 0 deletions assets/world/world_map007.tmx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.10" tiledversion="1.11.0" orientation="orthogonal" renderorder="right-down" width="16" height="16" tilewidth="32" tileheight="32" infinite="0" nextlayerid="2" nextobjectid="1">
<tileset firstgid="1" source="../Tileset1.tsx"/>
<layer id="1" name="Tile Layer 1" width="16" height="16">
<data encoding="csv">
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,0,0,0,0,0,0,5,5,0,0,0,0,0,0,2,
2,0,0,0,0,0,5,5,5,5,0,0,0,0,0,2,
2,0,0,0,0,5,5,5,5,5,5,0,0,0,0,2,
2,0,0,0,0,5,5,5,5,5,5,0,0,0,0,2,
2,0,0,0,0,0,5,5,5,5,0,0,0,0,0,2,
2,0,0,0,0,0,0,5,5,0,0,0,0,0,0,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
</data>
</layer>
</map>
Loading

0 comments on commit 6324e40

Please sign in to comment.