let x = (self.pos.x / lvl.grid.cell_size as f64).min(lvl.grid.width as f64 - 1.0).max(0.0) as usize;
let y = (self.pos.y / lvl.grid.cell_size as f64).min(lvl.grid.height as f64 - 1.0).max(0.0) as usize;
+ self.vel += lvl.gravity;
if lvl.grid.cells[x][y] {
- self.vel += lvl.gravity;
if self.vel.y > 0.0 && !(ctrl.mov.down() && ctrl.jump.is_pressed) {
self.vel.y = 0.0;
self.vel.x *= 0.9;
+ self.pos.y -= 1.0;
}
if !ctrl.mov.down() {
self.vel.y = -5.0;
}
}
- } else {
- self.vel += lvl.gravity;
}
self.pos += self.vel;