Compare commits

..

2 Commits

Author SHA1 Message Date
b98d283d09 Make Goomba hitbox larger
All checks were successful
continuous-integration/drone/push Build is passing
2022-06-21 08:52:21 +02:00
c8e749a145 Fix goomba movements 2022-06-21 08:50:43 +02:00

View File

@ -20,7 +20,7 @@ GoombaBlock::GoombaBlock(int x, int y,
addCollision(SDLPP::RectColider(0, 0.25, 0.1, 0.6, NPC_LEFT_SIDE_DETECT)); addCollision(SDLPP::RectColider(0, 0.25, 0.1, 0.6, NPC_LEFT_SIDE_DETECT));
addCollision( addCollision(
SDLPP::RectColider(0.9, 0.25, 0.1, 0.6, NPC_RIGHT_SIDE_DETECT)); SDLPP::RectColider(0.9, 0.25, 0.1, 0.6, NPC_RIGHT_SIDE_DETECT));
addCollision(std::make_shared<SDLPP::RectColider>(0.5, 0, 0.2, 0.15, addCollision(std::make_shared<SDLPP::RectColider>(0.35, 0, 0.3, 0.15,
NPC_TOP_DETECT)); NPC_TOP_DETECT));
#ifndef EDITOR #ifndef EDITOR
setMovement(-0.19, 0); setMovement(-0.19, 0);
@ -58,7 +58,8 @@ void GoombaBlock::handleVisitor(SDLPP::Visitor &visitor) {
if (isOnGround()) { if (isOnGround()) {
setPos(getPos().getX(), g_visitor.getGroundY() - BLOCK_SIZE); 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()); setPos(g_visitor.getValidXPos(), getPos().getY());
setMovement(-getMovement().getX(), getMovement().getY()); setMovement(-getMovement().getX(), getMovement().getY());
} }