Character unable to jump when falling off an edge
This commit is contained in:
parent
6b098f6cde
commit
29df5f872d
|
@ -81,6 +81,7 @@ pub struct Character {
|
||||||
|
|
||||||
impl Character {
|
impl Character {
|
||||||
|
|
||||||
|
/// Creates a character in (0, 0).
|
||||||
fn generic(controls: Option<Controls>) -> Character {
|
fn generic(controls: Option<Controls>) -> Character {
|
||||||
Character {
|
Character {
|
||||||
position: Vector2::new(0.0, 0.0),
|
position: Vector2::new(0.0, 0.0),
|
||||||
|
@ -121,6 +122,13 @@ impl Character {
|
||||||
self.jump_counter = self.max_jump;
|
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 {
|
impl Updatable for Character {
|
||||||
|
|
|
@ -43,6 +43,8 @@ impl Scene {
|
||||||
c.position.y = height;
|
c.position.y = height;
|
||||||
c.speed.y = 0.0;
|
c.speed.y = 0.0;
|
||||||
c.ground_collision();
|
c.ground_collision();
|
||||||
|
} else {
|
||||||
|
c.fall_off();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue