better collision handling

This commit is contained in:
2014-12-23 21:51:17 +01:00
parent 4c298d3a64
commit e313bbf80a
2 changed files with 36 additions and 17 deletions

View File

@@ -23,6 +23,12 @@ impl Player {
pub fn update(&mut self) {
self.velocity.y += self.gravity;
if self.velocity.y > 8.0 {
self.velocity.y = 8.0;
} else if self.velocity.y < -8.0 {
self.velocity.y = -8.0;
}
self.position.x += self.velocity.x;
self.position.y += self.velocity.y;
}