diff options
author | Nao Pross <naopross@thearcway.org> | 2018-12-17 04:45:02 +0100 |
---|---|---|
committer | Nao Pross <naopross@thearcway.org> | 2018-12-17 04:45:02 +0100 |
commit | 5a3a9a55eb3cdd816a97a9e6452ed1eed07b94cf (patch) | |
tree | 51d2c032b3a6b4b2dc9d05d4a16512c69bf7c553 /src/main.rs | |
parent | Add demo map (diff) | |
download | Subconscious-rs-5a3a9a55eb3cdd816a97a9e6452ed1eed07b94cf.tar.gz Subconscious-rs-5a3a9a55eb3cdd816a97a9e6452ed1eed07b94cf.zip |
Load tilesets from assets
Diffstat (limited to '')
-rw-r--r-- | src/main.rs | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/src/main.rs b/src/main.rs index 4d32b95..9eb709f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,43 +8,49 @@ use std::thread; use std::sync::{Arc, Mutex}; fn main() { - let state_mutex = Arc::new(Mutex::new(game::new())); + let game_state_mutex = Arc::new(Mutex::new(game::new())); - let state = state_mutex.clone(); + let game_state = game_state_mutex.clone(); let game_thread = thread::spawn(move || { loop { // aquire state resource - let mut state = match state.lock() { - Ok(state) => state, + let mut game_state = match game_state.lock() { + Ok(game_state) => game_state, Err(poisoned) => poisoned.into_inner(), }; - if state.running == false { + if game_state.running == false { break; } - game::update(&mut state); + game::update(&mut game_state); } }); - let state = state_mutex.clone(); + let game_state = game_state_mutex.clone(); let graphics_thread = thread::spawn(move || { let mut window = graphics::start(); while window.is_open() { - graphics::render(&mut window); + // aquire state resource + let game_state = match game_state.lock() { + Ok(game_state) => game_state, + Err(poisoned) => poisoned.into_inner(), + }; + + graphics::render(&mut window, &game_state); graphics::update(&mut window); } // aquire state resource - let mut state = match state.lock() { - Ok(state) => state, + let mut game_state = match game_state.lock() { + Ok(game_state) => game_state, Err(poisoned) => poisoned.into_inner(), }; // stop game thread - state.running = false; + game_state.running = false; }); // wait for both thread to die |