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
+13 -1
View File
@@ -8,7 +8,7 @@
class MarioVisitor : public SDLPP::Visitor {
public:
MarioVisitor(bool is_jumping, SDLPP::Scene &scene, bool &quit, int &coin_count) : jumping(is_jumping), _scene(scene), _quit(quit), _coin_count(coin_count) {}
MarioVisitor(bool is_jumping, SDLPP::Scene &scene, bool &quit, int &coin_count, std::vector< std::shared_ptr< MarioBlock > > &moving_objects) : jumping(is_jumping), _scene(scene), _quit(quit), _coin_count(coin_count), _moving_objects(moving_objects) {}
void visit( const SDLPP::RenderObject &obj ) override;
bool isOnGround() const {
return onGround;
@@ -90,6 +90,16 @@ public:
return coin_block;
}
bool hasMushroom() const {
return mushroom;
}
void setMushroomBlock(std::shared_ptr<MarioBlock> &mushroom) {
_scene.addObject(mushroom);
_scene.setZIndex(mushroom, 1);
_moving_objects.push_back(mushroom);
}
private:
bool onGround = false;
double groundY = 0;
@@ -110,6 +120,8 @@ private:
SDLPP::Scene &_scene;
bool &_quit;
int &_coin_count;
bool mushroom = false;
std::vector< std::shared_ptr< MarioBlock > > &_moving_objects;
};
#endif