equal
deleted
inserted
replaced
4 }; |
4 }; |
5 |
5 |
6 use hedgewars_engine::instance::EngineInstance; |
6 use hedgewars_engine::instance::EngineInstance; |
7 |
7 |
8 use integral_geometry::Point; |
8 use integral_geometry::Point; |
|
9 use std::time::Duration; |
9 |
10 |
10 fn init(event_loop: &EventsLoop, size: dpi::LogicalSize) -> WindowedContext { |
11 fn init(event_loop: &EventsLoop, size: dpi::LogicalSize) -> WindowedContext { |
11 use glutin::{ContextBuilder, WindowBuilder}; |
12 use glutin::{ContextBuilder, WindowBuilder}; |
12 |
13 |
13 let window = WindowBuilder::new() |
14 let window = WindowBuilder::new() |
46 let mut dragging = false; |
47 let mut dragging = false; |
47 |
48 |
48 use std::time::Instant; |
49 use std::time::Instant; |
49 |
50 |
50 let mut now = Instant::now(); |
51 let mut now = Instant::now(); |
|
52 let mut update = Instant::now(); |
51 |
53 |
52 let mut is_running = true; |
54 let mut is_running = true; |
53 while is_running { |
55 while is_running { |
54 let curr = Instant::now(); |
56 let curr = Instant::now(); |
55 let delta = curr - now; |
57 let delta = curr - now; |
56 now = curr; |
58 now = curr; |
57 let ms = delta.as_secs() as f64 * 1000.0 + delta.subsec_millis() as f64; |
59 let ms = delta.as_secs() as f64 * 1000.0 + delta.subsec_millis() as f64; |
58 window.set_title(&format!("hwengine {:.3}ms", ms)); |
60 window.set_title(&format!("hwengine {:.3}ms", ms)); |
|
61 |
|
62 if update.elapsed() > Duration::from_millis(10) { |
|
63 update = curr; |
|
64 engine.world.step() |
|
65 } |
59 |
66 |
60 event_loop.poll_events(|event| match event { |
67 event_loop.poll_events(|event| match event { |
61 Event::WindowEvent { event, .. } => match event { |
68 Event::WindowEvent { event, .. } => match event { |
62 WindowEvent::CloseRequested => { |
69 WindowEvent::CloseRequested => { |
63 is_running = false; |
70 is_running = false; |