From 176ff3de42cf473aa8ee962f738e3402c9618cf7 Mon Sep 17 00:00:00 2001 From: _ <_@_> Date: Sun, 9 Jan 2022 14:26:09 +0000 Subject: [PATCH] add prediction --- src/bin/platformer/main.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/bin/platformer/main.rs b/src/bin/platformer/main.rs index defe2be..adfeb56 100644 --- a/src/bin/platformer/main.rs +++ b/src/bin/platformer/main.rs @@ -364,7 +364,13 @@ async fn main () -> Result <()> { window.gl_make_current (&gl_ctx).unwrap (); - graphics.draw (&game_state.static_level, &game_state.logic, &mut gl_state, &level, &camera); + let prediction_frames = 4; + let mut predicted_logic = game_state.logic.clone (); + for _ in 0..prediction_frames { + predicted_logic.step (&game_state.static_level, &phys_params, p_gp); + } + + graphics.draw (&game_state.static_level, &predicted_logic, &mut gl_state, &level, &camera); graphics.frames += 1; if graphics.frames == next_upf_print {