implement adrenaline_jolt
This commit is contained in:
parent
c80fec0dd4
commit
41d97942de
12
src/hud.rs
12
src/hud.rs
|
@ -2,17 +2,19 @@ use crate::{settings, player};
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy::diagnostic::{DiagnosticsStore, FrameTimeDiagnosticsPlugin};
|
use bevy::diagnostic::{DiagnosticsStore, FrameTimeDiagnosticsPlugin};
|
||||||
|
|
||||||
|
const HUD_REFRESH_TIME: f32 = 0.5;
|
||||||
|
const FONT: &str = "tmp/fonts/NotoSansSC-Thin.ttf";
|
||||||
|
|
||||||
pub struct OutFlyHudPlugin;
|
pub struct OutFlyHudPlugin;
|
||||||
impl Plugin for OutFlyHudPlugin {
|
impl Plugin for OutFlyHudPlugin {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
app.add_systems(Startup, setup);
|
app.add_systems(Startup, setup);
|
||||||
app.add_systems(Update, (update, handle_input));
|
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)]
|
#[derive(Component)]
|
||||||
struct GaugesText;
|
struct GaugesText;
|
||||||
|
|
||||||
|
@ -109,8 +111,8 @@ fn update(
|
||||||
}
|
}
|
||||||
let oxygen = playervars.oxygen * 100.0;
|
let oxygen = playervars.oxygen * 100.0;
|
||||||
text.sections[3].value = format!("{oxygen:.1}%");
|
text.sections[3].value = format!("{oxygen:.1}%");
|
||||||
let adrenaline = playervars.adrenaline * 430.0;
|
let adrenaline = playervars.adrenaline * 990.0 + 10.0;
|
||||||
text.sections[5].value = format!("{adrenaline:.1}ppm");
|
text.sections[5].value = format!("{adrenaline:.0}pg/mL");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,9 +28,9 @@ pub struct PlayerVars {
|
||||||
impl Default for PlayerVars {
|
impl Default for PlayerVars {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
oxygen: 1.0,
|
oxygen: 0.1984,
|
||||||
adrenaline: 0.1,
|
adrenaline: 0.1,
|
||||||
adrenaline_jolt: 0.1,
|
adrenaline_jolt: 0.5,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,6 +60,12 @@ pub fn handle_input(
|
||||||
pub fn drain_resources(
|
pub fn drain_resources(
|
||||||
mut playervars:ResMut<PlayerVars>,
|
mut playervars:ResMut<PlayerVars>,
|
||||||
) {
|
) {
|
||||||
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);
|
playervars.oxygen = (playervars.oxygen - 0.000001).clamp(0.0, 1.0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue