Mario: mario detects enemies and bounces when he kills them/dies when they kill him

This commit is contained in:
2021-08-08 21:40:00 +02:00
parent 45ac4dad64
commit 94bf4fc39d
4 changed files with 21 additions and 3 deletions
+8
View File
@@ -53,6 +53,14 @@ void MarioVisitor::visit( const SDLPP::RenderObject &obj ) {
death = true;
_quit = true;
break;
case GOOMBA_ID:
if(from != MARIO_FLOOR_DETECT && from != MARIO_ENEMY_DETECT) {
death = true;
_quit = true;
} else {
_bounce = true;
}
break;
case STOP_MOVEMENT:
stop = true;
newX = obj.getDoubleRect().first.getX() +
+5
View File
@@ -100,6 +100,10 @@ public:
_moving_objects.push_back(mushroom);
}
bool shouldBounce() {
return _bounce;
}
private:
bool onGround = false;
double groundY = 0;
@@ -122,6 +126,7 @@ private:
int &_coin_count;
bool mushroom = false;
std::vector< std::shared_ptr< MarioBlock > > &_moving_objects;
bool _bounce = false;
};
#endif