air bag impl
This commit is contained in:
parent
da3b52e395
commit
2d6d1f3629
@ -67,7 +67,7 @@ impl ItemBase for StunGun {
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
|
||||
pub struct AirBag {
|
||||
extra_oxygen: u32,
|
||||
pub extra_oxygen: f32,
|
||||
pub level: u8,
|
||||
cost: u32,
|
||||
}
|
||||
@ -75,21 +75,21 @@ pub struct AirBag {
|
||||
impl AirBag {
|
||||
pub fn lvl1() -> Self {
|
||||
Self {
|
||||
extra_oxygen: 15,
|
||||
extra_oxygen: 0.15,
|
||||
level: 1,
|
||||
cost: 30,
|
||||
}
|
||||
}
|
||||
pub fn lvl2() -> Self {
|
||||
Self {
|
||||
extra_oxygen: 30,
|
||||
extra_oxygen: 0.30,
|
||||
level: 2,
|
||||
cost: 40,
|
||||
}
|
||||
}
|
||||
pub fn lvl3() -> Self {
|
||||
Self {
|
||||
extra_oxygen: 45,
|
||||
extra_oxygen: 0.45,
|
||||
level: 3,
|
||||
cost: 50,
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ pub fn update_player_movement(
|
||||
|
||||
// Update the player's breath
|
||||
game_core.player.breath_percent =
|
||||
(game_core.player.breath_percent - BREATH_DECREASE_PER_SECOND * dt as f32).clamp(0.0, 1.0);
|
||||
(game_core.player.breath_percent - BREATH_DECREASE_PER_SECOND * dt as f32).max(0.0);
|
||||
|
||||
// Only do this if the mouse is far enough away
|
||||
let player_stunned = game_core.player.stun_timer > 0.0;
|
||||
|
@ -66,6 +66,11 @@ impl Player {
|
||||
self.position = position;
|
||||
self.breath_percent = 1.0;
|
||||
self.boost_percent = 1.0;
|
||||
|
||||
// Handle an air bag being used
|
||||
if self.inventory.air_bag.is_some() {
|
||||
self.breath_percent += self.inventory.air_bag.as_ref().unwrap().extra_oxygen;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn collides_with_rec(&self, rectangle: &Rectangle) -> bool {
|
||||
|
Reference in New Issue
Block a user