Mario: teleport to hardcoded level

This commit is contained in:
2022-11-13 19:52:39 +01:00
parent 41ba43ed93
commit c5283000c7
14 changed files with 171 additions and 54 deletions
+11 -4
View File
@@ -6,13 +6,20 @@
void MarioVisitor::visit(const SDLPP::RenderObject &obj) {
auto id = obj.getId();
switch (id) {
case FLOOR_ID:
case BRICK_ID:
case BRICK_TOP_ID:
case PIPE_LEFT_BOTTOM_ID:
case PIPE_RIGHT_BOTTOM_ID:
case PIPE_LEFT_TOP_ID:
case PIPE_RIGHT_TOP_ID:
{
auto m_obj = dynamic_cast<const MarioBlock &>(obj);
if(m_obj.hasTeleport()) {
setTeleportLevel(m_obj.getTeleportLevel());
}
}
// fallthrough
case FLOOR_ID:
case BRICK_ID:
case BRICK_TOP_ID:
case STEP_ID:
case SIDEWAY_PIPE_END_TOP_ID:
case SIDEWAY_PIPE_END_BOTTOM_ID:
@@ -50,7 +57,7 @@ void MarioVisitor::visit(const SDLPP::RenderObject &obj) {
}
break;
case DEATH_ID:
_death = true;
_instant_death = true;
break;
case GOOMBA_ID:
if (from != MARIO_FLOOR_DETECT && from != MARIO_ENEMY_DETECT) {
+14
View File
@@ -21,6 +21,9 @@ public:
bool isDead() const {
return _death;
}
bool isInstantDead() const {
return _instant_death;
}
bool isStopped() const {
return stop;
}
@@ -124,6 +127,15 @@ public:
bool hasStar() const {
return _has_star;
}
bool hasTeleport() const {
return !teleport_level.empty();
}
const std::string &getTeleportLevel() const {
return teleport_level;
}
void setTeleportLevel(const std::string &level) {
teleport_level = level;
}
private:
bool onGround = false;
@@ -151,6 +163,8 @@ private:
bool _is_big = false;
bool _has_star = false;
bool _death = false;
bool _instant_death = false;
std::string teleport_level = "";
};
#endif