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
+16 -2
View File
@@ -99,7 +99,7 @@ void Mario::handleVisitor(SDLPP::Visitor &visitor) {
resetMovementY();
stop_jump = true;
}
if (m_visitor.shouldBounce()) {
if (m_visitor.shouldBounce() && getMovement().getY() > 0) {
addMovement(0, -bounce_speed);
}
// make sure Mario isn't stuck inside a wall
@@ -128,7 +128,7 @@ void Mario::handleVisitor(SDLPP::Visitor &visitor) {
}
}
if (m_visitor.hasMushroom()) {
setType(LandType::UNDERWORLD);
setBig();
}
if (m_visitor.levelEnd() && controllable) {
if (std::abs(getPos().getX() - m_visitor.getEndPos().getX()) <
@@ -137,8 +137,19 @@ void Mario::handleVisitor(SDLPP::Visitor &visitor) {
stopMovement();
}
}
if (m_visitor.isDead()) {
handleDeath();
}
#endif
}
void Mario::handleDeath() {
if (isBig() && ticks_till_vulnurable <= 0) {
unsetBig();
ticks_till_vulnurable = base_vulnurable_ticks;
} else if (ticks_till_vulnurable <= 0) {
setDeath();
}
}
void Mario::jump() {
if (!controllable) {
@@ -162,6 +173,9 @@ void Mario::stopJump() {
}
void Mario::custom_move(int ticks) {
if (ticks_till_vulnurable > 0) {
ticks_till_vulnurable -= ticks;
}
MarioBlock::custom_move(ticks);
if (!jumping && on_ground)
return;