Mario: top collision detection

This commit is contained in:
2021-05-23 23:57:29 +02:00
parent 8672830db8
commit bea479bf72
4 changed files with 12 additions and 1 deletions
+3
View File
@@ -73,6 +73,9 @@ void Mario::handleVisitor(MarioVisitor &visitor, SDLPP::Vec2D<double> previous_p
setPos(getPos().getX(), visitor.getGroundY() - BLOCK_SIZE);
}
}
if(visitor.topBlock() && getMovement().getY() < 0) {
resetMovementY();
}
// make sure Mario isn't stuck inside a wall
if ( visitor.isStopped() ||
( !visitor.canGoLeft() && previous_position.getX() > getPos().getX() ) ||