|
|
@ -23,7 +23,7 @@ pub fn texture(name: &str) -> String {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn get_level(lines: u32) -> u32 {
|
|
|
|
fn get_level(lines: u32) -> u32 {
|
|
|
|
return std::cmp::min(lines / LINES_PER_LEVEL, 15);
|
|
|
|
std::cmp::min(lines / LINES_PER_LEVEL, 15)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn get_update_interval(level: u32) -> u32 {
|
|
|
|
fn get_update_interval(level: u32) -> u32 {
|
|
|
@ -53,7 +53,7 @@ fn handle_resize_events(code: Key, current_scale: &mut u32, render_window: &mut
|
|
|
|
render_window.set_size(Vector2u::new(WINDOW_WIDTH, WINDOW_HEIGHT) * new_current_scale);
|
|
|
|
render_window.set_size(Vector2u::new(WINDOW_WIDTH, WINDOW_HEIGHT) * new_current_scale);
|
|
|
|
let mut file = std::fs::OpenOptions::new()
|
|
|
|
let mut file = std::fs::OpenOptions::new()
|
|
|
|
.write(true)
|
|
|
|
.write(true)
|
|
|
|
.open(&scale_file_path)
|
|
|
|
.open(scale_file_path)
|
|
|
|
.unwrap();
|
|
|
|
.unwrap();
|
|
|
|
file.write_all(new_current_scale.to_string().as_bytes()).unwrap();
|
|
|
|
file.write_all(new_current_scale.to_string().as_bytes()).unwrap();
|
|
|
|
file.flush().unwrap();
|
|
|
|
file.flush().unwrap();
|
|
|
@ -206,67 +206,64 @@ fn main() {
|
|
|
|
let mut new_highscore_sound = Sound::with_buffer(&new_highscore_buffer);
|
|
|
|
let mut new_highscore_sound = Sound::with_buffer(&new_highscore_buffer);
|
|
|
|
|
|
|
|
|
|
|
|
while window.is_open() {
|
|
|
|
while window.is_open() {
|
|
|
|
loop {
|
|
|
|
while let Some(event) = window.poll_event() {
|
|
|
|
match window.poll_event() {
|
|
|
|
match event {
|
|
|
|
Some(event) => match event {
|
|
|
|
Event::Closed | Event::KeyPressed {
|
|
|
|
Event::Closed | Event::KeyPressed {
|
|
|
|
code: Key::Q,
|
|
|
|
code: Key::Q,
|
|
|
|
alt: _,
|
|
|
|
alt: _,
|
|
|
|
ctrl: true,
|
|
|
|
ctrl: true,
|
|
|
|
shift: _,
|
|
|
|
shift: _,
|
|
|
|
system: _,
|
|
|
|
system: _,
|
|
|
|
} => window.close(),
|
|
|
|
} => window.close(),
|
|
|
|
Event::LostFocus => {
|
|
|
|
Event::LostFocus => {
|
|
|
|
toggle_pause = true;
|
|
|
|
toggle_pause = true;
|
|
|
|
paused_from_lost_focus = true;
|
|
|
|
paused_from_lost_focus = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
Event::KeyPressed {
|
|
|
|
|
|
|
|
code,
|
|
|
|
|
|
|
|
alt: _,
|
|
|
|
|
|
|
|
ctrl: true,
|
|
|
|
|
|
|
|
shift: _,
|
|
|
|
|
|
|
|
system: _,
|
|
|
|
|
|
|
|
} => {
|
|
|
|
|
|
|
|
handle_resize_events(code, &mut current_scale, &mut window, &scale_file_path);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
Event::KeyPressed {
|
|
|
|
|
|
|
|
code,
|
|
|
|
|
|
|
|
alt: _,
|
|
|
|
|
|
|
|
ctrl: _,
|
|
|
|
|
|
|
|
shift: _,
|
|
|
|
|
|
|
|
system: _,
|
|
|
|
|
|
|
|
} => match code {
|
|
|
|
|
|
|
|
Key::ESCAPE => toggle_pause = true,
|
|
|
|
|
|
|
|
Key::SPACE => snap = true,
|
|
|
|
|
|
|
|
Key::UP => rotate = true,
|
|
|
|
|
|
|
|
Key::DOWN => fast_forward = true,
|
|
|
|
|
|
|
|
Key::LEFT => {
|
|
|
|
|
|
|
|
move_left = true;
|
|
|
|
|
|
|
|
move_left_immediate = true;
|
|
|
|
|
|
|
|
move_clock.restart();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Key::RIGHT => {
|
|
|
|
|
|
|
|
move_right = true;
|
|
|
|
|
|
|
|
move_right_immediate = true;
|
|
|
|
|
|
|
|
move_clock.restart();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Event::KeyPressed {
|
|
|
|
|
|
|
|
code,
|
|
|
|
|
|
|
|
alt: _,
|
|
|
|
|
|
|
|
ctrl: true,
|
|
|
|
|
|
|
|
shift: _,
|
|
|
|
|
|
|
|
system: _,
|
|
|
|
|
|
|
|
} => {
|
|
|
|
|
|
|
|
handle_resize_events(code, &mut current_scale, &mut window, &scale_file_path);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
Event::KeyPressed {
|
|
|
|
|
|
|
|
code,
|
|
|
|
|
|
|
|
alt: _,
|
|
|
|
|
|
|
|
ctrl: _,
|
|
|
|
|
|
|
|
shift: _,
|
|
|
|
|
|
|
|
system: _,
|
|
|
|
|
|
|
|
} => match code {
|
|
|
|
|
|
|
|
Key::ESCAPE => toggle_pause = true,
|
|
|
|
|
|
|
|
Key::SPACE => snap = true,
|
|
|
|
|
|
|
|
Key::UP => rotate = true,
|
|
|
|
|
|
|
|
Key::DOWN => fast_forward = true,
|
|
|
|
|
|
|
|
Key::LEFT => {
|
|
|
|
|
|
|
|
move_left = true;
|
|
|
|
|
|
|
|
move_left_immediate = true;
|
|
|
|
|
|
|
|
move_clock.restart();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Key::RIGHT => {
|
|
|
|
|
|
|
|
move_right = true;
|
|
|
|
|
|
|
|
move_right_immediate = true;
|
|
|
|
|
|
|
|
move_clock.restart();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
_ => {}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
Event::KeyReleased {
|
|
|
|
|
|
|
|
code,
|
|
|
|
|
|
|
|
alt: _,
|
|
|
|
|
|
|
|
ctrl: _,
|
|
|
|
|
|
|
|
shift: _,
|
|
|
|
|
|
|
|
system: _,
|
|
|
|
|
|
|
|
} => match code {
|
|
|
|
|
|
|
|
Key::DOWN => fast_forward = false,
|
|
|
|
|
|
|
|
Key::LEFT => move_left = false,
|
|
|
|
|
|
|
|
Key::RIGHT => move_right = false,
|
|
|
|
|
|
|
|
_ => {}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
_ => {}
|
|
|
|
_ => {}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
None => break,
|
|
|
|
Event::KeyReleased {
|
|
|
|
|
|
|
|
code,
|
|
|
|
|
|
|
|
alt: _,
|
|
|
|
|
|
|
|
ctrl: _,
|
|
|
|
|
|
|
|
shift: _,
|
|
|
|
|
|
|
|
system: _,
|
|
|
|
|
|
|
|
} => match code {
|
|
|
|
|
|
|
|
Key::DOWN => fast_forward = false,
|
|
|
|
|
|
|
|
Key::LEFT => move_left = false,
|
|
|
|
|
|
|
|
Key::RIGHT => move_right = false,
|
|
|
|
|
|
|
|
_ => {}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
_ => {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -297,8 +294,8 @@ fn main() {
|
|
|
|
|
|
|
|
|
|
|
|
if paused {
|
|
|
|
if paused {
|
|
|
|
loop {
|
|
|
|
loop {
|
|
|
|
match window.wait_event() {
|
|
|
|
if let Some(event) = window.wait_event() {
|
|
|
|
Some(event) => match event {
|
|
|
|
match event {
|
|
|
|
Event::Closed | Event::KeyPressed {
|
|
|
|
Event::Closed | Event::KeyPressed {
|
|
|
|
code: Key::Q,
|
|
|
|
code: Key::Q,
|
|
|
|
alt: _,
|
|
|
|
alt: _,
|
|
|
@ -332,7 +329,6 @@ fn main() {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
_ => {}
|
|
|
|
_ => {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_ => {}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|