diff options
author | Baitinq <manuelpalenzuelamerino@gmail.com> | 2023-02-22 11:01:45 +0100 |
---|---|---|
committer | Baitinq <manuelpalenzuelamerino@gmail.com> | 2023-02-22 11:01:45 +0100 |
commit | 2e3df118bd41be9aac2c3eb12a731732d75b92a6 (patch) | |
tree | 805334ed7af09a5ab1fd65ff82f6ea7643baa6e2 | |
parent | SDL: Wait and fetch events from the event pump (diff) | |
download | kyukai-2e3df118bd41be9aac2c3eb12a731732d75b92a6.tar.gz kyukai-2e3df118bd41be9aac2c3eb12a731732d75b92a6.tar.bz2 kyukai-2e3df118bd41be9aac2c3eb12a731732d75b92a6.zip |
Loop: Quit if 'ESC' pressed
-rw-r--r-- | src/main.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs index 218ef96..6c7565c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,5 @@ +use sdl2::event::Event; +use sdl2::keyboard::Keycode; use sdl2::pixels::Color; pub fn main() { @@ -24,12 +26,16 @@ pub fn main() { let mut sdl_event_pump = sdl_context .event_pump() .expect("Couldn't get the SDL2 event pump!"); - loop { + 'running: loop { for event in sdl_event_pump.wait_iter() { match event { - _ => { - println!("Event!"); + Event::KeyDown { + keycode: Some(Keycode::Escape), + .. + } => { + break 'running; } + _ => {} } } } |