- commit
- 3473b5223e89342290524d41079d774b7e0806a3
- parent
- cd5b337f2dd727dee5fa32279f55a3668a057cd5
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2023-02-19 17:08
simplify framerate calculation
Diffstat
| M | src/main.rs | 6 | +++--- |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs
@@ -36,6 +36,7 @@ fn main() {
36 36
37 37 while RUNNING.load(Ordering::Relaxed) {
38 38 let time1 = time::Instant::now();
-1 39 let dt = (time1 - time0).as_secs_f32();
39 40
40 41 while let Some(c) = input.getch() {
41 42 match c {
@@ -55,7 +56,7 @@ fn main() {
55 56 }
56 57 }
57 58
58 -1 game.step((time1 - time0).as_secs_f32());
-1 59 game.step(dt);
59 60 game.render(&mut screen);
60 61
61 62 let xp_bar = (screen.width as f32 * (game.player.xp - game.player.last_level) as f32
@@ -78,6 +79,7 @@ fn main() {
78 79 }
79 80
80 81 screen.render();
-1 82 print!("{:?}", 1.0 / dt);
81 83
82 84 if game.player.health < 0.0 {
83 85 println!("\nyou died (score: {})", game.player.xp);
@@ -88,8 +90,6 @@ fn main() {
88 90 if TICK > time2 - time1 {
89 91 thread::sleep(TICK - (time2 - time1));
90 92 }
91 -1 let time3 = time::Instant::now();
92 -1 print!("{:?}", 1.0 / (time3 - time1).as_secs_f64());
93 93 time0 = time1;
94 94 }
95 95 }