diff options
| author | LLLL Colonq <llll@colonq> | 2025-03-11 14:55:07 -0400 |
|---|---|---|
| committer | LLLL Colonq <llll@colonq> | 2025-03-11 14:55:07 -0400 |
| commit | 2a7b0690f4dbc33c9fc2b0b1eeb814b44eb20c30 (patch) | |
| tree | 2d48e393109c61fe3ce591d634f2f80e9a9774df /src/state.rs | |
| parent | 22fbeca88a781aca7bcc965ac8189244497671d6 (diff) | |
Update
Diffstat (limited to 'src/state.rs')
| -rw-r--r-- | src/state.rs | 12 |
1 files changed, 6 insertions, 6 deletions
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<G>(&mut self, ctx: &context::Context, game: &mut G) where G: Game { + pub fn run_update<G>(&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<G>(&mut self, ctx: &context::Context, game: &mut G) where G: Game { + pub fn run_render<G>(&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(()) } } |
