mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-27 13:14:15 -08:00
lose messages done
This commit is contained in:
@@ -51,7 +51,7 @@ impl Game {
|
||||
let (v, a) = (self.terminal_velocity, self.acceleration);
|
||||
let terminal_velocity_time = v / a;
|
||||
|
||||
let mut final_altitude = self.altitude;
|
||||
let mut final_altitude;
|
||||
|
||||
for i in 0..=8 {
|
||||
let dt = i as f32 * self.interval;
|
||||
|
||||
@@ -2,6 +2,19 @@ use crate::celestial_body;
|
||||
use rand::Rng;
|
||||
use std::io;
|
||||
|
||||
const DEATH_MESSAGES: [&str; 10] = [
|
||||
"REQUIESCAT IN PACE.",
|
||||
"MAY THE ANGEL OF HEAVEN LEAD YOU INTO PARADISE.",
|
||||
"REST IN PEACE.",
|
||||
"SON-OF-A-GUN.",
|
||||
"#$%&&%!$",
|
||||
"A KICK IN THE PANTS IS A BOOST IF YOU'RE HEADED RIGHT.",
|
||||
"HMMM. SHOULD HAVE PICKED A SHORTER TIME.",
|
||||
"MUTTER. MUTTER. MUTTER.",
|
||||
"PUSHING UP DAISIES.",
|
||||
"EASY COME, EASY GO.",
|
||||
];
|
||||
|
||||
pub fn read_line() -> String {
|
||||
let mut input = String::new();
|
||||
io::stdin()
|
||||
@@ -80,6 +93,15 @@ fn get_random_float(min: f32, max: f32) -> f32 {
|
||||
}
|
||||
|
||||
pub fn print_splat(t: f32) {
|
||||
println!("{}\t\tSPLAT!", t);
|
||||
//get random death message
|
||||
print_random(format!("{}\t\tSPLAT!", t).as_str(), &DEATH_MESSAGES);
|
||||
}
|
||||
|
||||
fn print_random(msg: &str, choices: &[&str]) {
|
||||
use rand::seq::SliceRandom;
|
||||
use rand::thread_rng;
|
||||
|
||||
let mut rng = thread_rng();
|
||||
|
||||
println!("{}", msg);
|
||||
println!("\n{}", choices.choose(&mut rng).unwrap());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user