diff options
author | Nao Pross <naopross@thearcway.org> | 2018-12-17 03:04:40 +0100 |
---|---|---|
committer | Nao Pross <naopross@thearcway.org> | 2018-12-17 03:04:40 +0100 |
commit | bd48081e33fe84e7ad8a38966334732c4559720c (patch) | |
tree | df7df83021e2aa3dfd354735cf322a42a69eb531 /src/main.rs | |
parent | Add game state object shared across threads (diff) | |
download | Subconscious-rs-bd48081e33fe84e7ad8a38966334732c4559720c.tar.gz Subconscious-rs-bd48081e33fe84e7ad8a38966334732c4559720c.zip |
Add loading of embedded resources
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs index e2353e7..4d32b95 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,6 @@ +#[macro_use] +extern crate rust_embed; + mod game; mod graphics; @@ -5,9 +8,9 @@ use std::thread; use std::sync::{Arc, Mutex}; fn main() { - let state_ = Arc::new(Mutex::new(game::new())); + let state_mutex = Arc::new(Mutex::new(game::new())); - let state = state_.clone(); + let state = state_mutex.clone(); let game_thread = thread::spawn(move || { loop { // aquire state resource @@ -25,7 +28,7 @@ fn main() { }); - let state = state_.clone(); + let state = state_mutex.clone(); let graphics_thread = thread::spawn(move || { let mut window = graphics::start(); @@ -40,9 +43,11 @@ fn main() { Err(poisoned) => poisoned.into_inner(), }; + // stop game thread state.running = false; }); + // wait for both thread to die graphics_thread.join().unwrap(); game_thread.join().unwrap(); } |