rust/hwrunner/src/main.rs
changeset 14721 8e74d4eb89f5
parent 14719 4df1aac5f090
--- a/rust/hwrunner/src/main.rs	Fri Mar 22 23:46:48 2019 +0300
+++ b/rust/hwrunner/src/main.rs	Sat Mar 23 01:07:23 2019 +0300
@@ -6,6 +6,7 @@
 use hedgewars_engine::instance::EngineInstance;
 
 use integral_geometry::Point;
+use std::time::Duration;
 
 fn init(event_loop: &EventsLoop, size: dpi::LogicalSize) -> WindowedContext {
     use glutin::{ContextBuilder, WindowBuilder};
@@ -48,6 +49,7 @@
     use std::time::Instant;
 
     let mut now = Instant::now();
+    let mut update = Instant::now();
 
     let mut is_running = true;
     while is_running {
@@ -57,6 +59,11 @@
         let ms = delta.as_secs() as f64 * 1000.0 + delta.subsec_millis() as f64;
         window.set_title(&format!("hwengine {:.3}ms", ms));
 
+        if update.elapsed() > Duration::from_millis(10) {
+            update = curr;
+            engine.world.step()
+        }
+
         event_loop.poll_events(|event| match event {
             Event::WindowEvent { event, .. } => match event {
                 WindowEvent::CloseRequested => {