Skip to content

Commit

Permalink
tiled: Reorganize level data
Browse files Browse the repository at this point in the history
Switch from the built-in sprite sheet to individual tiles, all of which
are now embedded in the binary.
  • Loading branch information
daniel-thompson committed Jan 13, 2024
1 parent bfd8beb commit a812639
Show file tree
Hide file tree
Showing 10 changed files with 2,281 additions and 230 deletions.
714 changes: 655 additions & 59 deletions src/assets/level1.tmx

Large diffs are not rendered by default.

912 changes: 903 additions & 9 deletions src/assets/mod.rs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/helpers/tiled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ impl AssetLoader for TiledLoader {
let tile_path = tmx_dir.join(&img.source);
let asset_path = AssetPath::from(tile_path.to_str().expect("tile_path is not UTF-8").to_string());
//let asset_path = AssetPath::from(tile_path);
log::info!("Loading tile image from {asset_path:?} as image ({tileset_index}, {tile_id})");
log::debug!("Loading tile image from {asset_path:?} as image ({tileset_index}, {tile_id})");
let texture: Handle<Image> = load_context.load(asset_path.clone());
tile_image_offsets
.insert((tileset_index, tile_id), tile_images.len() as u32);
Expand All @@ -149,7 +149,7 @@ impl AssetLoader for TiledLoader {
let tmx_dir = std::path::PathBuf::from("embedded://");
let tile_path = tmx_dir.join(&img.source);
let asset_path = AssetPath::from(tile_path.to_str().expect("tile_path is not UTF-8").to_string());
log::info!("Loading tile image from {asset_path:?}");
log::debug!("Loading tile image from {asset_path:?}");
let texture: Handle<Image> = load_context.load(asset_path.clone());

TilemapTexture::Single(texture.clone())
Expand Down
274 changes: 274 additions & 0 deletions tiled/asphalt_road.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,274 @@
<?xml version="1.0" encoding="UTF-8"?>
<tileset version="1.10" tiledversion="1.10.2" name="Asphalt road" tilewidth="128" tileheight="128" tilecount="90" columns="0">
<grid orientation="orthogonal" width="1" height="1"/>
<tile id="0">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt01.png"/>
</tile>
<tile id="1">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt02.png"/>
</tile>
<tile id="2">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt03.png"/>
</tile>
<tile id="3">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt04.png"/>
</tile>
<tile id="4">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt05.png"/>
</tile>
<tile id="5">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt06.png"/>
</tile>
<tile id="6">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt07.png"/>
</tile>
<tile id="7">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt08.png"/>
</tile>
<tile id="8">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt09.png"/>
</tile>
<tile id="9">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt10.png"/>
</tile>
<tile id="10">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt11.png"/>
</tile>
<tile id="11">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt12.png"/>
</tile>
<tile id="12">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt13.png"/>
</tile>
<tile id="13">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt14.png"/>
</tile>
<tile id="14">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt15.png"/>
</tile>
<tile id="15">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt16.png"/>
</tile>
<tile id="16">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt17.png"/>
</tile>
<tile id="17">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt18.png"/>
</tile>
<tile id="18">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt19.png"/>
</tile>
<tile id="19">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt20.png"/>
</tile>
<tile id="20">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt21.png"/>
</tile>
<tile id="21">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt22.png"/>
</tile>
<tile id="22">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt23.png"/>
</tile>
<tile id="23">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt24.png"/>
</tile>
<tile id="24">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt25.png"/>
</tile>
<tile id="25">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt26.png"/>
</tile>
<tile id="26">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt27.png"/>
</tile>
<tile id="27">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt28.png"/>
</tile>
<tile id="28">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt29.png"/>
</tile>
<tile id="29">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt30.png"/>
</tile>
<tile id="30">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt31.png"/>
</tile>
<tile id="31">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt32.png"/>
</tile>
<tile id="32">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt33.png"/>
</tile>
<tile id="33">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt34.png"/>
</tile>
<tile id="34">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt35.png"/>
</tile>
<tile id="35">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt36.png"/>
</tile>
<tile id="36">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt37.png"/>
</tile>
<tile id="37">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt38.png"/>
</tile>
<tile id="38">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt39.png"/>
</tile>
<tile id="39">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt40.png"/>
</tile>
<tile id="40">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt41.png"/>
</tile>
<tile id="41">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt42.png"/>
</tile>
<tile id="42">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt43.png"/>
</tile>
<tile id="43">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt44.png"/>
</tile>
<tile id="44">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt45.png"/>
</tile>
<tile id="45">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt46.png"/>
</tile>
<tile id="46">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt47.png"/>
</tile>
<tile id="47">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt48.png"/>
</tile>
<tile id="48">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt49.png"/>
</tile>
<tile id="49">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt50.png"/>
</tile>
<tile id="50">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt51.png"/>
</tile>
<tile id="51">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt52.png"/>
</tile>
<tile id="52">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt53.png"/>
</tile>
<tile id="53">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt54.png"/>
</tile>
<tile id="54">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt55.png"/>
</tile>
<tile id="55">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt56.png"/>
</tile>
<tile id="56">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt57.png"/>
</tile>
<tile id="57">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt58.png"/>
</tile>
<tile id="58">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt59.png"/>
</tile>
<tile id="59">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt60.png"/>
</tile>
<tile id="60">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt61.png"/>
</tile>
<tile id="61">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt62.png"/>
</tile>
<tile id="62">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt63.png"/>
</tile>
<tile id="63">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt64.png"/>
</tile>
<tile id="64">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt65.png"/>
</tile>
<tile id="65">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt66.png"/>
</tile>
<tile id="66">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt67.png"/>
</tile>
<tile id="67">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt68.png"/>
</tile>
<tile id="68">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt69.png"/>
</tile>
<tile id="69">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt70.png"/>
</tile>
<tile id="70">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt71.png"/>
</tile>
<tile id="71">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt72.png"/>
</tile>
<tile id="72">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt73.png"/>
</tile>
<tile id="73">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt74.png"/>
</tile>
<tile id="74">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt75.png"/>
</tile>
<tile id="75">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt76.png"/>
</tile>
<tile id="76">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt77.png"/>
</tile>
<tile id="77">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt78.png"/>
</tile>
<tile id="78">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt79.png"/>
</tile>
<tile id="79">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt80.png"/>
</tile>
<tile id="80">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt81.png"/>
</tile>
<tile id="81">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt82.png"/>
</tile>
<tile id="82">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt83.png"/>
</tile>
<tile id="83">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt84.png"/>
</tile>
<tile id="84">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt85.png"/>
</tile>
<tile id="85">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt86.png"/>
</tile>
<tile id="86">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt87.png"/>
</tile>
<tile id="87">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt88.png"/>
</tile>
<tile id="88">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt89.png"/>
</tile>
<tile id="89">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Asphalt road/road_asphalt90.png"/>
</tile>
</tileset>
46 changes: 46 additions & 0 deletions tiled/dirt.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<tileset version="1.10" tiledversion="1.10.2" name="Dirt" tilewidth="128" tileheight="128" tilecount="14" columns="0">
<grid orientation="orthogonal" width="1" height="1"/>
<tile id="0">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Dirt/land_dirt01.png"/>
</tile>
<tile id="1">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Dirt/land_dirt02.png"/>
</tile>
<tile id="2">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Dirt/land_dirt03.png"/>
</tile>
<tile id="3">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Dirt/land_dirt04.png"/>
</tile>
<tile id="4">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Dirt/land_dirt05.png"/>
</tile>
<tile id="5">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Dirt/land_dirt06.png"/>
</tile>
<tile id="6">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Dirt/land_dirt07.png"/>
</tile>
<tile id="7">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Dirt/land_dirt08.png"/>
</tile>
<tile id="8">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Dirt/land_dirt09.png"/>
</tile>
<tile id="9">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Dirt/land_dirt10.png"/>
</tile>
<tile id="10">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Dirt/land_dirt11.png"/>
</tile>
<tile id="11">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Dirt/land_dirt12.png"/>
</tile>
<tile id="12">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Dirt/land_dirt13.png"/>
</tile>
<tile id="13">
<image width="128" height="128" source="../src/assets/kenney_racing-pack/PNG/Tiles/Dirt/land_dirt14.png"/>
</tile>
</tileset>
Loading

0 comments on commit a812639

Please sign in to comment.