summaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorJon Santmyer <jon@jonsantmyer.com>2026-05-03 18:37:35 -0400
committerJon Santmyer <jon@jonsantmyer.com>2026-05-03 18:37:35 -0400
commitdd5de0107163bc3ea3898c07089d00f82feeec5e (patch)
treed8feef7d8a89c01ef183c6b032b29cd6d451aaec /src/main.rs
parent759d5d27c7773c7fe8b165ce08b57204db990b74 (diff)
downloadsystemic4x-dd5de0107163bc3ea3898c07089d00f82feeec5e.tar.gz
systemic4x-dd5de0107163bc3ea3898c07089d00f82feeec5e.tar.bz2
systemic4x-dd5de0107163bc3ea3898c07089d00f82feeec5e.zip
add tick and subtick system for solar system orbit updates
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs12
1 files changed, 7 insertions, 5 deletions
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);
});
}
}