mirror of
https://github.com/mii443/rustris.git
synced 2025-08-22 16:25:42 +00:00
add game speed
This commit is contained in:
@ -16,6 +16,7 @@ pub struct GameData {
|
|||||||
pub show_ghost: bool,
|
pub show_ghost: bool,
|
||||||
pub hold_mino: Option<Mino>,
|
pub hold_mino: Option<Mino>,
|
||||||
pub score: i64,
|
pub score: i64,
|
||||||
|
pub game_speed: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GameData {
|
impl GameData {
|
||||||
@ -94,6 +95,7 @@ impl GameData {
|
|||||||
show_ghost,
|
show_ghost,
|
||||||
hold_mino: None,
|
hold_mino: None,
|
||||||
score: 0,
|
score: 0,
|
||||||
|
game_speed: 0.5,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
10
src/main.rs
10
src/main.rs
@ -147,7 +147,12 @@ fn main() {
|
|||||||
if *exit_flag_rc.lock().unwrap() {
|
if *exit_flag_rc.lock().unwrap() {
|
||||||
break;
|
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();
|
let mut rustris_rc = rustris_rc.lock().unwrap();
|
||||||
if !rustris_rc.move_mino(1, 0) {
|
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 mut stdout = stdout_rc.lock().unwrap();
|
||||||
let buf = rustris_rc.lock().unwrap().show();
|
let buf = rustris_rc.show();
|
||||||
execute!(stdout, Print(buf)).unwrap()
|
execute!(stdout, Print(buf)).unwrap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,7 @@ impl Rustris {
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.game_data.score += clear_lines * 100;
|
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 {
|
pub fn get_next_mino(&mut self) -> Mino {
|
||||||
|
Reference in New Issue
Block a user