update_on_ground_flag(hit);
- if (hit.top || hit.bottom) {
- physic.set_velocity_y(0);
+ if (hit.top) {
+ if (physic.get_velocity_y() < 0) physic.set_velocity_y(0);
+ }
+ if (hit.bottom) {
+ if (physic.get_velocity_y() > 0) physic.set_velocity_y(0);
}
- if ((hit.left && dir == LEFT) || (hit.right && dir == RIGHT)) {
+ if ((hit.left && (hit.slope_normal.y == 0) && (dir == LEFT)) || (hit.right && (hit.slope_normal.y == 0) && (dir == RIGHT))) {
turn_around();
}