Mario: Add restart and background color for menus
This commit is contained in:
@@ -50,14 +50,11 @@ void MarioVisitor::visit(const SDLPP::RenderObject &obj) {
|
||||
}
|
||||
break;
|
||||
case DEATH_ID:
|
||||
// TODO remove death?
|
||||
death = true;
|
||||
_quit = true;
|
||||
_death = true;
|
||||
break;
|
||||
case GOOMBA_ID:
|
||||
if (from != MARIO_FLOOR_DETECT && from != MARIO_ENEMY_DETECT) {
|
||||
death = true;
|
||||
_quit = true;
|
||||
_death = true;
|
||||
} else {
|
||||
_bounce = true;
|
||||
}
|
||||
|
||||
@@ -8,17 +8,17 @@
|
||||
|
||||
class MarioVisitor : public SDLPP::Visitor {
|
||||
public:
|
||||
MarioVisitor(bool is_jumping, SDLPP::Scene &scene, bool &quit,
|
||||
MarioVisitor(bool is_jumping, SDLPP::Scene &scene, bool &death,
|
||||
int &coin_count,
|
||||
std::vector<std::shared_ptr<MarioBlock>> &moving_objects)
|
||||
: jumping(is_jumping), _scene(scene), _quit(quit),
|
||||
: jumping(is_jumping), _scene(scene), _death(death),
|
||||
_coin_count(coin_count), _moving_objects(moving_objects) {}
|
||||
void visit(const SDLPP::RenderObject &obj) override;
|
||||
bool isOnGround() const {
|
||||
return onGround;
|
||||
}
|
||||
bool isDead() const {
|
||||
return death;
|
||||
return _death;
|
||||
}
|
||||
bool isStopped() const {
|
||||
return stop;
|
||||
@@ -111,7 +111,6 @@ public:
|
||||
private:
|
||||
bool onGround = false;
|
||||
double groundY = 0;
|
||||
bool death = false;
|
||||
bool stop = false;
|
||||
double newX{};
|
||||
uint64_t from = -1;
|
||||
@@ -126,7 +125,7 @@ private:
|
||||
SDLPP::Vec2D<double> movement_blockage;
|
||||
std::shared_ptr<MarioBlock> coin_block = nullptr;
|
||||
SDLPP::Scene &_scene;
|
||||
bool &_quit;
|
||||
bool &_death;
|
||||
int &_coin_count;
|
||||
bool mushroom = false;
|
||||
std::vector<std::shared_ptr<MarioBlock>> &_moving_objects;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "goomba_visitor.hpp"
|
||||
|
||||
std::shared_ptr<SDLPP::Visitor>
|
||||
getVisitor(const MarioBlock &block, SDLPP::Scene &scene, bool &quit,
|
||||
getVisitor(const MarioBlock &block, SDLPP::Scene &scene, bool &death,
|
||||
int &coin_count,
|
||||
std::vector<std::shared_ptr<MarioBlock>> &moving_objects) {
|
||||
std::shared_ptr<SDLPP::Visitor> result{};
|
||||
@@ -13,7 +13,7 @@ getVisitor(const MarioBlock &block, SDLPP::Scene &scene, bool &quit,
|
||||
case MARIO_ID:
|
||||
result = std::static_pointer_cast<SDLPP::Visitor>(
|
||||
std::make_shared<MarioVisitor>(block.getMovement().getY() < 0,
|
||||
scene, quit, coin_count,
|
||||
scene, death, coin_count,
|
||||
moving_objects));
|
||||
break;
|
||||
case MUSHROOM_ID:
|
||||
|
||||
Reference in New Issue
Block a user