Mario: mushroom interaction with Mario

This commit is contained in:
2021-08-07 21:42:51 +02:00
parent 7b2adac922
commit f04dc1e23b
4 changed files with 30 additions and 5 deletions
+9 -3
View File
@@ -27,6 +27,8 @@ Mario::Mario(int x, int y, const std::shared_ptr< SDLPP::Renderer > &renderer) :
SDLPP::RectColider( 0.9, 0, 0.1, 0.1, MARIO_TOP_LEFT_DETECT ) );
top_collision = std::make_shared<SDLPP::RectColider>( 0.5, 0, 0.2, 0.15, MARIO_TOP_DETECT );
addCollision( top_collision );
addCollision(
SDLPP::RectColider( 0, 0, 1, 1, MARIO_ID ) );
setColiderColor("#FF0000");
setStatic( false );
}
@@ -69,7 +71,7 @@ void Mario::handleVisitor(SDLPP::Visitor &visitor) {
on_ground = m_visitor.isOnGround();
if(!jumping && on_ground) {
resetMovementY();
setTextureSourceRect(MARIO_STANDING_SRC);
setBaseRect(MARIO_STANDING_SRC);
if(getMovement().getX() != 0)
resumeAnimation();
// for some reason falling of the edge causes on_ground to be true, but
@@ -102,6 +104,9 @@ void Mario::handleVisitor(SDLPP::Visitor &visitor) {
setPos( objPos.getX() - BLOCK_SIZE, getPos().getY() );
}
}
if(m_visitor.hasMushroom()) {
setType(LandType::UNDERWORLD);
}
#endif
}
@@ -115,7 +120,7 @@ void Mario::jump() {
slow_jump = getPos().getY() - 2*BLOCK_SIZE;
addMovement( 0, -jump_movement );
ticks_till_gravity = base_gravity_ticks;
setTextureSourceRect(MARIO_JUMP_SRC);
setBaseRect(MARIO_JUMP_SRC);
pauseAnimation();
}
@@ -144,8 +149,9 @@ void Mario::custom_move( int ticks ) {
}
}
void Mario::visit(SDLPP::Visitor &/*UNUSED*/) {
void Mario::visit(SDLPP::Visitor &visitor) {
// TODO
visitor.visit(*this);
}
void Mario::setWorldTypeSrc(LandType::Value /*UNUSED*/) {