summaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs11
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();
}