diff --git a/src/game_data.rs b/src/game_data.rs index 629cf43..829f3bb 100644 --- a/src/game_data.rs +++ b/src/game_data.rs @@ -16,6 +16,7 @@ pub struct GameData { pub show_ghost: bool, pub hold_mino: Option, pub score: i64, + pub game_speed: f32, } impl GameData { @@ -94,6 +95,7 @@ impl GameData { show_ghost, hold_mino: None, score: 0, + game_speed: 0.5, } } } diff --git a/src/main.rs b/src/main.rs index 347ce08..3bf70aa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -147,7 +147,12 @@ fn main() { if *exit_flag_rc.lock().unwrap() { break; } - thread::sleep(Duration::from_secs_f32(0.5)); + let mut game_speed = 0.5f32; + { + let rustris_rc = rustris_rc.lock().unwrap(); + game_speed = rustris_rc.game_data.game_speed; + } + thread::sleep(Duration::from_secs_f32(game_speed)); { let mut rustris_rc = rustris_rc.lock().unwrap(); if !rustris_rc.move_mino(1, 0) { @@ -169,8 +174,9 @@ fn main() { } } { + let mut rustris_rc = rustris_rc.lock().unwrap(); let mut stdout = stdout_rc.lock().unwrap(); - let buf = rustris_rc.lock().unwrap().show(); + let buf = rustris_rc.show(); execute!(stdout, Print(buf)).unwrap() } } diff --git a/src/rustris.rs b/src/rustris.rs index 6041ecd..8373850 100644 --- a/src/rustris.rs +++ b/src/rustris.rs @@ -43,6 +43,7 @@ impl Rustris { } self.game_data.score += clear_lines * 100; + self.game_data.game_speed += 0.01 * clear_lines as f32; } pub fn get_next_mino(&mut self) -> Mino {