survivor

graphical action game for the linux terminal
git clone https://git.ce9e.org/survivor.git

commit
8fff7961fceae073492401e0d9e33d0e252090dc
parent
c52fe1a81629fd8e117c6f01b1c9c66e1a1a7e2f
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2023-04-17 04:35
use constant dt for calculations

fixes huge dt after SIGSTOP

Diffstat

M src/main.rs 7 +------

1 files changed, 1 insertions, 6 deletions


diff --git a/src/main.rs b/src/main.rs

@@ -74,8 +74,6 @@ fn main() {
   74    74     signal(libc::SIGWINCH, handle_signal as libc::sighandler_t);
   75    75     signal(libc::SIGTSTP, handle_signal as libc::sighandler_t);
   76    76 
   77    -1     let mut time0 = time::Instant::now();
   78    -1 
   79    77     while !NEED_QUIT.load(Ordering::Relaxed) {
   80    78         if NEED_STOP.load(Ordering::Relaxed) {
   81    79             screen.restore();
@@ -87,7 +85,6 @@ fn main() {
   87    85             // when SIGCONT is received
   88    86             screen.init();
   89    87             input.cbreak();
   90    -1             time0 = time::Instant::now();
   91    88             NEED_STOP.store(false, Ordering::Relaxed);
   92    89         }
   93    90 
@@ -97,7 +94,6 @@ fn main() {
   97    94         }
   98    95 
   99    96         let time1 = time::Instant::now();
  100    -1         let dt = (time1 - time0).as_secs_f32();
  101    97 
  102    98         while let Some(c) = input.getch() {
  103    99             match c {
@@ -126,7 +122,7 @@ fn main() {
  126   122         };
  127   123         let width = win::iconvert_x(win.width);
  128   124         let height = win::iconvert_y(win.height);
  129    -1         game.step(dt, width, height);
   -1   125         game.step(TICK.as_secs_f32(), width, height);
  130   126         game.render(&mut win);
  131   127 
  132   128         render_xp_bar(&game.player, &mut screen);
@@ -143,6 +139,5 @@ fn main() {
  143   139         if TICK > time2 - time1 {
  144   140             thread::sleep(TICK - (time2 - time1));
  145   141         }
  146    -1         time0 = time1;
  147   142     }
  148   143 }