Reverse should_quit logic

This commit is contained in:
Sijmen 2018-07-29 23:10:05 +02:00
parent f4a352d5cd
commit ce3efce2d9

View file

@ -50,19 +50,14 @@ fn world_to_screen(x: i32, y: i32, z: i32) -> (i32, i32) {
fn update(event_pump: &mut EventPump, game_state: &mut GameState) -> bool {
for event in event_pump.poll_iter() {
match event {
Event::Quit { .. } => return true,
Event::Quit { .. } => return false,
Event::KeyDown {
keycode: Some(keycode),
..
} => {
match keycode {
Keycode::Escape => return true,
Keycode::Up => game_state.camera_y -= 8,
Keycode::Down => game_state.camera_y += 8,
Keycode::Left => game_state.camera_x -= 8,
Keycode::Right => game_state.camera_x += 8,
Keycode::Escape => return false,
_ => {}
};
}
@ -73,12 +68,14 @@ fn update(event_pump: &mut EventPump, game_state: &mut GameState) -> bool {
} => {
game_state.camera_panning = true;
}
Event::MouseButtonUp {
mouse_btn: MouseButton::Right,
..
} => {
game_state.camera_panning = false;
}
Event::MouseMotion {
xrel: x, yrel: y, ..
} => {
@ -92,7 +89,7 @@ fn update(event_pump: &mut EventPump, game_state: &mut GameState) -> bool {
};
}
false
true
}
fn render(
@ -165,8 +162,7 @@ pub fn main() {
canvas.set_draw_color(Color::RGB(48, 48, 48));
loop {
let should_quit = update(&mut event_pump, &mut game_state);
if should_quit {
if !update(&mut event_pump, &mut game_state) {
return;
}