Rearrange window draw code into a function (curses).
@@ -115,6 +115,17 @@ pub fn main_loop<GS: GameState>(mut bterm: BTerm, mut gamestate: GS) -> Result<(
gamestate.tick(&mut bterm);
+ full_redraw()?;
+
+ crate::hal::fps_sleep(BACKEND.lock().frame_sleep_time, &now, prev_ms);
+ }
+
+ endwin();
+ Ok(())
+}
+
+// Completely redraws the back-end
+fn full_redraw() -> Result<()> {
let be = BACKEND.lock();
let window = be.window.as_ref().unwrap();
@@ -178,11 +189,5 @@ pub fn main_loop<GS: GameState>(mut bterm: BTerm, mut gamestate: GS) -> Result<(
}
window.refresh();
-
- crate::hal::fps_sleep(be.frame_sleep_time, &now, prev_ms);
- }
-
- endwin();
Ok(())
}
\ No newline at end of file
-
