Add ECSRenderer for improved integration of rendering and ECS

- Introduced ECSRenderer struct to manage the connection between the renderer and the ECS.
- Implemented methods for spawning and despawning meshes within the ECS.
- Updated main function to utilize ECSRenderer for rendering and object management.
- Added a new Time module to handle frame timing and updates.
This commit is contained in:
reo 2025-07-01 23:25:57 +03:00
parent cdbac0d4ab
commit 7e4168eee5
3 changed files with 101 additions and 30 deletions

34
src/time.rs Normal file
View file

@ -0,0 +1,34 @@
use std::time::{Duration, Instant};
#[derive(Clone, Debug)]
pub struct Time {
last: Instant,
delta: Duration,
total: Duration,
}
impl Time {
pub fn new() -> Self {
let now = Instant::now();
Self {
last: now,
delta: Duration::ZERO,
total: Duration::ZERO,
}
}
pub fn tick(&mut self) {
let now = Instant::now();
self.delta = now - self.last;
self.total += self.delta;
self.last = now;
}
pub fn delta_seconds(&self) -> f32 {
self.delta.as_secs_f32()
}
pub fn total_seconds(&self) -> f32 {
self.total.as_secs_f32()
}
}