use std::error::Error; use tiled::Map; // embedded resources #[derive(RustEmbed)] #[folder = "res/maps"] pub struct MapAssets; // game state pub struct State { pub running: bool, pub map: Map, } pub fn new() -> State { // load demo map let demo_map_asset = match MapAssets::get("demo.tmx") { Some(asset) => asset, None => panic!("Failed to load demo map asset"), }; let demo_map = match tiled::parse(demo_map_asset.as_ref()) { Ok(map) => map, Err(e) => panic!("Failed to parse demo map: {}", e.description()), }; // allow only orthogonal maps assert_eq!(demo_map.orientation, tiled::Orientation::Orthogonal); return State { running: true, map: demo_map }; } pub fn update(_state: &mut State) { }