survivor

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

commit
dbf953c91c3f794eae051f7ad80bb3b93e5a0486
parent
8fff7961fceae073492401e0d9e33d0e252090dc
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2023-04-17 04:48
fix "you died" message after alternate screen

Diffstat

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

1 files changed, 11 insertions, 3 deletions


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

@@ -64,7 +64,7 @@ fn signal(sig: libc::c_int, handler: libc::sighandler_t) {
   64    64     }
   65    65 }
   66    66 
   67    -1 fn main() {
   -1    67 fn run_in_screen() -> Option<f32> {
   68    68     let pid = std::process::id();
   69    69     let mut input = input::Input::new();
   70    70     let mut screen = term::Screen::new();
@@ -131,8 +131,7 @@ fn main() {
  131   131         screen.render();
  132   132 
  133   133         if game.player.health < 0.0 {
  134    -1             println!("\nyou died (score: {})", game.player.xp as usize);
  135    -1             break;
   -1   134             return Some(game.player.xp);
  136   135         }
  137   136 
  138   137         let time2 = time::Instant::now();
@@ -140,4 +139,13 @@ fn main() {
  140   139             thread::sleep(TICK - (time2 - time1));
  141   140         }
  142   141     }
   -1   142 
   -1   143     return None
   -1   144 }
   -1   145 
   -1   146 fn main() {
   -1   147     let result = run_in_screen();
   -1   148     if let Some(score) = result {
   -1   149         println!("\nyou died (total XP: {:.0})", score);
   -1   150     }
  143   151 }