From dd5de0107163bc3ea3898c07089d00f82feeec5e Mon Sep 17 00:00:00 2001 From: Jon Santmyer Date: Sun, 3 May 2026 18:37:35 -0400 Subject: add tick and subtick system for solar system orbit updates --- src/main.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 7a7e3a1..72cd3dd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -22,7 +22,7 @@ use winit::application::{ApplicationHandler}; use winit::keyboard::PhysicalKey; use winit::window::{Window, WindowId, WindowAttributes}; -use solar_system::SolarSystem; +use solar_system::*; use crate::timeman::TimeMan; use crate::window::GameWindow; @@ -64,12 +64,14 @@ impl GameState pub fn new() -> Self { let timeman = TimeMan::new(0); - let sol_system = match SolarSystem::new_from_known_star(0, "sol") + let mut sol_system = match SolarSystem::new_from_known_star(0, "sol") { Ok(system) => system, Err(e) => panic!("Unable to create sol system : {}", e) }; + sol_system.update(timeman.seconds()); + Self { timeman: timeman, solar_systems: vec![ sol_system ] @@ -89,9 +91,9 @@ impl GameState &mut self, dt: Duration) { - self.timeman.update(); - self.solar_systems.iter_mut().for_each(|solar_system| { - solar_system.update(self.timeman.seconds()); + let ticks = self.timeman.update(); + ticks.iter().for_each(|time| { + solar_system::update_systems(self.solar_systems.iter_mut(), *time); }); } } -- cgit v1.2.3