Character unable to jump when falling off an edge

This commit is contained in:
2018-10-04 10:19:40 +02:00
parent 6b098f6cde
commit 29df5f872d
2 changed files with 10 additions and 0 deletions
+8
View File
@@ -81,6 +81,7 @@ pub struct Character {
impl Character {
/// Creates a character in (0, 0).
fn generic(controls: Option<Controls>) -> 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 {