diff --git a/mario/mario.cpp b/mario/mario.cpp index bd7bbe5..fc9fe7a 100644 --- a/mario/mario.cpp +++ b/mario/mario.cpp @@ -86,7 +86,8 @@ void Mario::handleVisitor(MarioVisitor &visitor) { // TODO more readable function names if ( visitor.isStopped() ) { setPos( visitor.getStopX(), getPos().getY()); - } else if ( visitor.canGoLeft() != visitor.canGoRight() ) { + } else if ( visitor.canGoLeft() != visitor.canGoRight() && !(on_ground && visitor.getMovementBlockage().getY() > getPos().getY() + BLOCK_SIZE/2) ) { + // only stop mario on ground if the block obstructs at least half of him (important for bug when mario lands from a high jump and is teleported if visitor is fired at wrong moment) SDLPP::Vec2D next_pos = { visitor.getMovementBlockage().getX() + (visitor.canGoLeft() * -1 + visitor.canGoRight() * 1) * BLOCK_SIZE, getPos().getY() }; setPos(next_pos); } else if (visitor.moveTop() && jumping && !stop_jump) {