From 2a7b0690f4dbc33c9fc2b0b1eeb814b44eb20c30 Mon Sep 17 00:00:00 2001 From: LLLL Colonq Date: Tue, 11 Mar 2025 14:55:07 -0400 Subject: Update --- src/state.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/state.rs') diff --git a/src/state.rs b/src/state.rs index 7b2de9e..1316cf2 100644 --- a/src/state.rs +++ b/src/state.rs @@ -483,7 +483,7 @@ impl State { game.request_return(ctx, self, res); } - pub fn run_update(&mut self, ctx: &context::Context, game: &mut G) where G: Game { + pub fn run_update(&mut self, ctx: &context::Context, game: &mut G) -> utils::Erm<()> where G: Game { let now = now(ctx); let diff = now - self.last; @@ -496,20 +496,19 @@ impl State { self.acc -= DELTA_TIME; self.tick += 1; - // TODO: handle failure here in a nicer way - game.update(ctx, self).expect("game update failed"); + game.update(ctx, self)?; // if a lot of time has elapsed (e.g. if window is unfocused and not // running update loop), prevent "death spiral" if self.acc >= DELTA_TIME { self.acc = 0.0 } } + Ok(()) } - pub fn run_render(&mut self, ctx: &context::Context, game: &mut G) where G: Game { + pub fn run_render(&mut self, ctx: &context::Context, game: &mut G) -> utils::Erm<()> where G: Game { self.render_framebuffer.bind(&ctx); - // TODO: handle failure here in a nicer way - game.render(ctx, self).expect("game render failed"); + game.render(ctx, self)?; self.screen.bind(&ctx); ctx.clear_color(glam::Vec4::new(0.0, 0.0, 0.0, 0.0)); @@ -517,5 +516,6 @@ impl State { self.shader_upscale.bind(&ctx); self.render_framebuffer.bind_texture(&ctx); ctx.render_no_geometry(); + Ok(()) } } -- cgit v1.2.3