game/mario/visitors/visitor_generator.cpp

32 lines
1.0 KiB
C++
Raw Normal View History

#include "visitor_generator.hpp"
#include "../objectids.hpp"
#include "mario_visitor.hpp"
2021-08-07 19:42:51 +00:00
#include "mushroom_visitor.hpp"
2021-08-08 19:45:05 +00:00
#include "goomba_visitor.hpp"
2021-10-18 08:10:43 +00:00
std::shared_ptr<SDLPP::Visitor>
getVisitor(const MarioBlock &block, SDLPP::Scene &scene, bool &death,
2021-10-18 08:10:43 +00:00
int &coin_count,
std::vector<std::shared_ptr<MarioBlock>> &moving_objects) {
std::shared_ptr<SDLPP::Visitor> result{};
switch (block.getId()) {
case MARIO_ID:
result = std::static_pointer_cast<SDLPP::Visitor>(
std::make_shared<MarioVisitor>(block.getMovement().getY() < 0,
scene, death, coin_count,
2021-10-18 08:10:43 +00:00
moving_objects));
break;
case MUSHROOM_ID:
result = std::static_pointer_cast<SDLPP::Visitor>(
std::make_shared<MushroomVisitor>());
break;
case GOOMBA_ID:
result = std::static_pointer_cast<SDLPP::Visitor>(
std::make_shared<GoombaVisitor>());
break;
default:
break;
}
return result;
}