summaryrefslogtreecommitdiffstats
path: root/src/game.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/game.rs')
-rw-r--r--src/game.rs27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/game.rs b/src/game.rs
index ab04b21..335e9da 100644
--- a/src/game.rs
+++ b/src/game.rs
@@ -1,15 +1,36 @@
+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 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()),
+ };
-pub fn new() -> State {
return State {
running: true,
+ map: demo_map
};
}
-pub fn update(state: &mut State) {
+pub fn update(_state: &mut State) {
} \ No newline at end of file