Mario: add basic big mario logic

This commit is contained in:
2022-09-25 19:44:28 +02:00
parent 09cb13195c
commit 4109cfe1af
12 changed files with 156 additions and 57 deletions
+3 -2
View File
@@ -7,7 +7,7 @@
GoombaBlock::GoombaBlock(int x, int y,
std::shared_ptr<SDLPP::Renderer> &renderer)
: MarioBlock(x, y, renderer, g_enemies_texture, GOOMBA_WALK_ANIM[0],
true, true) {
false, false) {
#ifndef EDITOR
setAnimationFrames(GOOMBA_WALK_ANIM);
setAnimationSpeed(12.5);
@@ -22,6 +22,7 @@ GoombaBlock::GoombaBlock(int x, int y,
SDLPP::RectColider(0.9, 0.25, 0.1, 0.6, NPC_RIGHT_SIDE_DETECT));
addCollision(std::make_shared<SDLPP::RectColider>(0.35, 0, 0.3, 0.15,
NPC_TOP_DETECT));
setBouncable(false);
#ifndef EDITOR
setMovement(-0.19, 0);
#endif
@@ -58,7 +59,7 @@ void GoombaBlock::handleVisitor(SDLPP::Visitor &visitor) {
if (isOnGround()) {
setPos(getPos().getX(), g_visitor.getGroundY() - BLOCK_SIZE);
}
if((!g_visitor.canGoLeft() && getMovement().getX() < 0) ||
if ((!g_visitor.canGoLeft() && getMovement().getX() < 0) ||
(!g_visitor.canGoRight() && getMovement().getX() > 0)) {
setPos(g_visitor.getValidXPos(), getPos().getY());
setMovement(-getMovement().getX(), getMovement().getY());