1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
pub mod core; pub mod rendering; pub mod input; pub use crate::core::*; pub use crate::rendering::*; pub use crate::input::*; pub use storm::{DisplayMode, Vsync}; use storm::*; use storm::time::*; static mut _GAME: Option<Box<dyn Game>> = None; static mut _SETTINGS: Option<GameSettings> = None; pub fn start(game: Box<dyn Game>, settings: GameSettings) { unsafe { _GAME = Some(game); _SETTINGS = Some(settings.clone()); } Engine::start(settings.render_settings, run); } fn run(mut storm: Engine) { let (mut game, mut settings) = unsafe { (_GAME.take().unwrap(), _SETTINGS.take().unwrap()) }; let mut clock = Clock::new(settings.tick_rate); let mut is_active = true; let mut input = Input::new(); let mut render_engine = RenderEngine::new(settings.render_settings); while is_active { input.update(&mut storm); if input.is_close_requested() { is_active = false; break; } game.update(clock.get_delta()); render_engine.update(&mut storm, &mut game); clock.tick(); } }