pub struct FrameStarted {
pub frame: u64,
pub delta: f32,
pub total_time: f64,
}Expand description
Emitted at the beginning of each frame.
This event provides timing information for the new frame. Use it to update game logic, animations, and physics with consistent delta time.
§Timing Fields
frame: Monotonically increasing frame counter (starts at 0)delta: Time elapsed since the previous frame in secondstotal_time: Total time elapsed since engine start in seconds
§Example
ⓘ
use goud_engine::core::events::FrameStarted;
use goud_engine::core::event::Events;
fn update_game(events: &Events<FrameStarted>) {
let mut reader = events.reader();
for event in reader.read() {
// Update physics with delta time
let velocity_change = 9.8 * event.delta; // gravity
// Check if it's a new second for FPS display
let prev_second = (event.total_time - event.delta as f64) as u64;
let curr_second = event.total_time as u64;
if curr_second > prev_second {
println!("Frame {} - Total time: {:.1}s", event.frame, event.total_time);
}
}
}Fields§
§frame: u64The frame number (0-indexed, monotonically increasing).
delta: f32Time elapsed since the previous frame, in seconds.
total_time: f64Total time elapsed since engine start, in seconds.
Implementations§
Trait Implementations§
Source§impl Clone for FrameStarted
impl Clone for FrameStarted
Source§fn clone(&self) -> FrameStarted
fn clone(&self) -> FrameStarted
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for FrameStarted
impl Debug for FrameStarted
Source§impl Default for FrameStarted
impl Default for FrameStarted
Source§impl PartialEq for FrameStarted
impl PartialEq for FrameStarted
impl Copy for FrameStarted
impl StructuralPartialEq for FrameStarted
Auto Trait Implementations§
impl Freeze for FrameStarted
impl RefUnwindSafe for FrameStarted
impl Send for FrameStarted
impl Sync for FrameStarted
impl Unpin for FrameStarted
impl UnsafeUnpin for FrameStarted
impl UnwindSafe for FrameStarted
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().