From 05429036fb3ac9fd75ae876fba184384641dc1e4 Mon Sep 17 00:00:00 2001 From: alexdevteam Date: Mon, 31 Jan 2022 20:14:50 +0100 Subject: [PATCH] Fix map asset path --- examples/sfml/main.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/examples/sfml/main.rs b/examples/sfml/main.rs index 24a38fb7..71358b22 100644 --- a/examples/sfml/main.rs +++ b/examples/sfml/main.rs @@ -10,7 +10,7 @@ use sfml::{ system::{Vector2f, Vector2u}, window::{ContextSettings, Key, Style}, }; -use std::{path::Path, time::Duration}; +use std::{env, path::PathBuf, time::Duration}; use tiled::{LayerData, LayerTile, Map}; use tilesheet::Tilesheet; @@ -89,7 +89,14 @@ impl Drawable for Level { } fn main() { - let map = Map::parse_file(Path::new(MAP_PATH)).unwrap(); + let map = Map::parse_file( + PathBuf::from( + env::var("CARGO_MANIFEST_DIR") + .expect("To run the example, use `cargo run --example sfml`"), + ) + .join(MAP_PATH), + ) + .unwrap(); let level = Level::from_map(map); let mut window = create_window();