diff --git a/src/engine/character/mod.rs b/src/engine/character/mod.rs index 03f952c..4257ffc 100644 --- a/src/engine/character/mod.rs +++ b/src/engine/character/mod.rs @@ -81,6 +81,7 @@ pub struct Character { impl Character { + /// Creates a character in (0, 0). fn generic(controls: Option) -> Character { Character { position: Vector2::new(0.0, 0.0), @@ -121,6 +122,13 @@ impl Character { self.jump_counter = self.max_jump; } + /// Make the player fall. + pub fn fall_off(&mut self) { + if self.jump_counter == self.max_jump { + self.jump_counter -= 1; + } + } + } impl Updatable for Character { diff --git a/src/engine/scene/mod.rs b/src/engine/scene/mod.rs index c1aa726..ea4253a 100644 --- a/src/engine/scene/mod.rs +++ b/src/engine/scene/mod.rs @@ -43,6 +43,8 @@ impl Scene { c.position.y = height; c.speed.y = 0.0; c.ground_collision(); + } else { + c.fall_off(); } } }