Character unable to jump when falling off an edge

This commit is contained in:
Thomas Forgione 2018-10-04 10:19:40 +02:00
parent 6b098f6cde
commit 29df5f872d
No known key found for this signature in database
GPG Key ID: 203DAEA747F48F41
2 changed files with 10 additions and 0 deletions

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 {

View File

@ -43,6 +43,8 @@ impl Scene {
c.position.y = height;
c.speed.y = 0.0;
c.ground_collision();
} else {
c.fall_off();
}
}
}