From 41d97942deda25cd2a8cfbac75d30c169ec2d98b Mon Sep 17 00:00:00 2001 From: hut Date: Sun, 17 Mar 2024 21:57:30 +0100 Subject: [PATCH] implement adrenaline_jolt --- src/hud.rs | 12 +++++++----- src/player.rs | 12 +++++++++--- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/hud.rs b/src/hud.rs index df2c592..1f7cbae 100644 --- a/src/hud.rs +++ b/src/hud.rs @@ -2,17 +2,19 @@ use crate::{settings, player}; use bevy::prelude::*; use bevy::diagnostic::{DiagnosticsStore, FrameTimeDiagnosticsPlugin}; +const HUD_REFRESH_TIME: f32 = 0.5; +const FONT: &str = "tmp/fonts/NotoSansSC-Thin.ttf"; + pub struct OutFlyHudPlugin; impl Plugin for OutFlyHudPlugin { fn build(&self, app: &mut App) { app.add_systems(Startup, setup); app.add_systems(Update, (update, handle_input)); - app.insert_resource(FPSUpdateTimer(Timer::from_seconds(0.25, TimerMode::Repeating))); + app.insert_resource(FPSUpdateTimer( + Timer::from_seconds(HUD_REFRESH_TIME, TimerMode::Repeating))); } } -const FONT: &str = "tmp/fonts/NotoSansSC-Thin.ttf"; - #[derive(Component)] struct GaugesText; @@ -109,8 +111,8 @@ fn update( } let oxygen = playervars.oxygen * 100.0; text.sections[3].value = format!("{oxygen:.1}%"); - let adrenaline = playervars.adrenaline * 430.0; - text.sections[5].value = format!("{adrenaline:.1}ppm"); + let adrenaline = playervars.adrenaline * 990.0 + 10.0; + text.sections[5].value = format!("{adrenaline:.0}pg/mL"); } } } diff --git a/src/player.rs b/src/player.rs index e0ab122..ced91e9 100644 --- a/src/player.rs +++ b/src/player.rs @@ -28,9 +28,9 @@ pub struct PlayerVars { impl Default for PlayerVars { fn default() -> Self { Self { - oxygen: 1.0, + oxygen: 0.1984, adrenaline: 0.1, - adrenaline_jolt: 0.1, + adrenaline_jolt: 0.5, } } } @@ -60,6 +60,12 @@ pub fn handle_input( pub fn drain_resources( mut playervars:ResMut, ) { - playervars.adrenaline = (playervars.adrenaline - 0.0001).clamp(0.0, 1.0); + if playervars.adrenaline_jolt.abs() > 1e-3 { + playervars.adrenaline_jolt *= 0.99; + } + else { + playervars.adrenaline_jolt = 0.0 + } + playervars.adrenaline = (playervars.adrenaline - 0.0001 + playervars.adrenaline_jolt * 0.01).clamp(0.0, 1.0); playervars.oxygen = (playervars.oxygen - 0.000001).clamp(0.0, 1.0); }