update example apps to not use sdl2 event types

This commit is contained in:
Gered 2023-01-18 17:03:21 -05:00
parent a7c91adaf0
commit 592be161c3
8 changed files with 31 additions and 22 deletions

View file

@ -1,8 +1,6 @@
use std::f64::consts::PI;
use std::path::Path; use std::path::Path;
use anyhow::Result; use anyhow::Result;
use sdl2::keyboard::Scancode;
use libretrogd::audio::*; use libretrogd::audio::*;
use libretrogd::graphics::*; use libretrogd::graphics::*;
@ -73,8 +71,11 @@ fn main() -> Result<()> {
while is_running { while is_running {
system.do_events_with(|event| { system.do_events_with(|event| {
if let sdl2::event::Event::Quit { .. } = event { match event {
is_running = false; SystemEvent::Quit => {
is_running = false;
},
_ => {}
} }
}); });

View file

@ -1,7 +1,6 @@
use std::path::Path; use std::path::Path;
use anyhow::Result; use anyhow::Result;
use sdl2::keyboard::Scancode;
use libretrogd::*; use libretrogd::*;
use libretrogd::graphics::*; use libretrogd::graphics::*;
@ -64,8 +63,11 @@ fn main() -> Result<()> {
while is_running { while is_running {
system.do_events_with(|event| { system.do_events_with(|event| {
if let sdl2::event::Event::Quit { .. } = event { match event {
is_running = false; SystemEvent::Quit => {
is_running = false;
},
_ => {}
} }
}); });

View file

@ -24,8 +24,11 @@ fn main() -> Result<()> {
while is_running && !states.is_empty() { while is_running && !states.is_empty() {
game.context.system.do_events_with(|event| { game.context.system.do_events_with(|event| {
if let sdl2::event::Event::Quit { .. } = event { match event {
is_running = false; SystemEvent::Quit => {
is_running = false;
},
_ => {}
} }
}); });

View file

@ -1,5 +1,3 @@
use sdl2::keyboard::Scancode;
use libretrogd::entities::*; use libretrogd::entities::*;
use libretrogd::events::*; use libretrogd::events::*;
use libretrogd::graphics::*; use libretrogd::graphics::*;

View file

@ -165,8 +165,11 @@ fn main() -> Result<()> {
while is_running && !states.is_empty() { while is_running && !states.is_empty() {
game.core.system.do_events_with(|event| { game.core.system.do_events_with(|event| {
if let sdl2::event::Event::Quit { .. } = event { match event {
is_running = false SystemEvent::Quit => {
is_running = false;
},
_ => {}
} }
}); });

View file

@ -1,11 +1,9 @@
use std::path::Path; use std::path::Path;
use sdl2::keyboard::Scancode;
use libretrogd::entities::*; use libretrogd::entities::*;
use libretrogd::graphics::*; use libretrogd::graphics::*;
use libretrogd::math::Vector2;
use libretrogd::states::*; use libretrogd::states::*;
use libretrogd::system::*;
use crate::entities::*; use crate::entities::*;
use crate::Game; use crate::Game;

View file

@ -1,5 +1,4 @@
use anyhow::Result; use anyhow::Result;
use sdl2::keyboard::Scancode;
use libretrogd::{SCREEN_HEIGHT, SCREEN_WIDTH}; use libretrogd::{SCREEN_HEIGHT, SCREEN_WIDTH};
use libretrogd::entities::*; use libretrogd::entities::*;
@ -195,8 +194,11 @@ fn main() -> Result<()> {
while is_running && !states.is_empty() { while is_running && !states.is_empty() {
game.core.system.do_events_with(|event| { game.core.system.do_events_with(|event| {
if let sdl2::event::Event::Quit { .. } = event { match event {
is_running = false; SystemEvent::Quit => {
is_running = false;
},
_ => {}
} }
}); });

View file

@ -1,5 +1,4 @@
use anyhow::Result; use anyhow::Result;
use sdl2::keyboard::Scancode;
use libretrogd::{SCREEN_BOTTOM, SCREEN_RIGHT}; use libretrogd::{SCREEN_BOTTOM, SCREEN_RIGHT};
use libretrogd::graphics::*; use libretrogd::graphics::*;
@ -17,8 +16,11 @@ fn main() -> Result<()> {
while is_running { while is_running {
system.do_events_with(|event| { system.do_events_with(|event| {
if let sdl2::event::Event::Quit { .. } = event { match event {
is_running = false; SystemEvent::Quit => {
is_running = false;
},
_ => {}
} }
}); });