pub fn check_update_time_forced(&mut self, target_fps: u32, iteration: &mut u32) -> bool {
        let target_dt = fps_as_duration(target_fps);
        if self.residual_update_dt > target_dt
            || (*iteration == 0 && self.fps() < 2. * target_fps as f64)
        {
            *iteration += 1;
            self.residual_update_dt = self
                .residual_update_dt
                .checked_sub(target_dt)
                .unwrap_or_default();
            true
        } else {
            false
        }
    }
/// This is a variant of `check_update_time` which intends you to pass an iteration
/// counter. If the iteration counter is zero, it will do an update regardless of
/// whether there's enough remaining time, and set the residual delta time to zero.
/// This helps avoid cascading stutters where the game performs no updates one frame
/// and then many the next.
///
/// ```rust
/// # use hv::{prelude::*, timer::{self, TimeContext}};
/// # fn update_game_physics() -> Result<()> { Ok(()) }
/// # struct State;
/// # impl State {
/// fn update(&mut self, ctx: &mut TimeContext) -> Result<()> {
///     ctx.tick();
///     let mut counter = 0;
///     while ctx.check_update_time_forced(60, &mut counter) {
///         update_game_physics()?;
///     }
///     Ok(())
/// }
/// # }
/// ```
This is a variant of `check_update_time` which intends you to pass an iteration
counter. If the iteration counter is zero, it will do an update regardless of
whether there's enough remaining time, and set the residual delta time to zero.
This helps avoid cascading stutters where the game performs no updates one frame
and then many the next.


This is a variant of ` check_update_time ` which intends you to pass an iteration counter . If the iteration counter is zero it will do an update regardless of whether there ' s enough remaining time and set the residual delta time to zero . This helps avoid cascading stutters where the game performs no updates one frame and then many the next .
pub fn check_update_time_forced(&mut self, target_fps: u32, iteration: &mut u32) -> bool {
        let target_dt = fps_as_duration(target_fps);
        if self.residual_update_dt > target_dt
            || (*iteration == 0 && self.fps() < 2. * target_fps as f64)
        {
            *iteration += 1;
            self.residual_update_dt = self
                .residual_update_dt
                .checked_sub(target_dt)
                .unwrap_or_default();
            true
        } else {
            false
        }
    }
pub fn check_update_time_forced ( & mut self , target_fps : u32 , iteration : & mut u32 ) -> bool { let target_dt = fps_as_duration ( target_fps ) ; if self . residual_update_dt > target_dt || ( * iteration == 0 && self . fps ( ) < 2. * target_fps as f64 ) { * iteration += 1 ; self . residual_update_dt = self . residual_update_dt . checked_sub ( target_dt ) . unwrap_or_default ( ) ; true } else { false } }
This is a variant of `check_update_time` which intends you to pass an iteration
counter.
This is a variant of ` check_update_time ` which intends you to pass an iteration counter .
&mut self
target_fps
u32
iteration
&mut u32
&mut self
target_fps
u32
iteration
&mut u32
use hv::{prelude::*, timer::{self, timecontext}};
None
fn update_game_physics() -> result<()> { ok(()) }
None
struct state;
None
impl state {
fn update(&mut self, ctx: &mut TimeContext) -> Result<()> {
ctx.tick();
let mut counter = 0;
while ctx.check_update_time_forced(60, &mut counter) {
update_game_physics()?;
}
Ok(())
}
fn update ( &mut self ctx : &mut TimeContext ) - > Result< () > { ctx . tick () ; let mut counter = 0 ; while ctx . check_update_time_forced ( 60 &mut counter ) { update_game_physics () ? ; } Ok (( )) }
}
None