Fix goomba movements

This commit is contained in:
zv0n 2022-06-21 08:50:43 +02:00
parent e87495db2e
commit c8e749a145

View File

@ -58,7 +58,8 @@ void GoombaBlock::handleVisitor(SDLPP::Visitor &visitor) {
if (isOnGround()) {
setPos(getPos().getX(), g_visitor.getGroundY() - BLOCK_SIZE);
}
if (!g_visitor.canGoLeft() || !g_visitor.canGoRight()) {
if((!g_visitor.canGoLeft() && getMovement().getX() < 0) ||
(!g_visitor.canGoRight() && getMovement().getX() > 0)) {
setPos(g_visitor.getValidXPos(), getPos().getY());
setMovement(-getMovement().getX(), getMovement().getY());
}