Mario: destroy blocks 1 at a time, if jumping and would hit only with small side, move Mario a bit so the jump is successful

This commit is contained in:
2021-05-25 12:26:04 +02:00
parent 7390f684f5
commit 7ed8b0f4e1
6 changed files with 40 additions and 21 deletions
+2 -1
View File
@@ -4,6 +4,7 @@
#include "sprites.hpp"
#include "editor_visitor.hpp"
#include <unordered_map>
#include "mario_visitor.hpp"
MarioBlock::MarioBlock( int x, int y,
std::shared_ptr< SDLPP::Renderer > renderer,
@@ -22,7 +23,7 @@ void MarioBlock::visit( SDLPP::Visitor &visitor ) {
visitor.getVisitorType() == VisitorType::Modifier ) {
destroy();
}
if(visitor.getFromId() == MARIO_TOP_DETECT && _destructible) {
if(visitor.getFromId() == MARIO_TOP_DETECT && _destructible && dynamic_cast<MarioVisitor&>(visitor).canDestroy()) {
destroy();
}
visitor.visit( *this );