zv0n
4109cfe1af
Some checks reported errors
continuous-integration/drone/push Build encountered an error
80 lines
2.3 KiB
C++
80 lines
2.3 KiB
C++
#include "mario_visitor.hpp"
|
|
#include "../../sdlpp/sdlpp_renderobject.hpp"
|
|
#include "../objectids.hpp"
|
|
#include "../sprites.hpp"
|
|
|
|
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:
|
|
case STEP_ID:
|
|
case SIDEWAY_PIPE_END_TOP_ID:
|
|
case SIDEWAY_PIPE_END_BOTTOM_ID:
|
|
case SIDEWAY_PIPE_MIDDLE_BOTTOM_ID:
|
|
case SIDEWAY_PIPE_MIDDLE_TOP_ID:
|
|
case SIDEWAY_PIPE_CONNECTOR_BOTTOM_ID:
|
|
case SIDEWAY_PIPE_CONNECTOR_TOP_ID:
|
|
case TREE_PLATFORM_TOP_LEFT_ID:
|
|
case TREE_PLATFORM_TOP_RIGHT_ID:
|
|
case MUSHROOM_PLATFORM_TOP_MIDDLE_ID:
|
|
case MUSHROOM_PLATFORM_TOP_LEFT_ID:
|
|
case MUSHROOM_PLATFORM_TOP_RIGHT_ID:
|
|
case CANNON_TOWER_ID:
|
|
case CANNON_PEDESTAL_ID:
|
|
case CANNON_ID:
|
|
if (from == MARIO_FLOOR_DETECT) {
|
|
onGround = true;
|
|
groundY = obj.getPos().getY();
|
|
} else if (from == MARIO_LEFT_SIDE_DETECT) {
|
|
if (!left && !right) {
|
|
movement_blockage = obj.getPos();
|
|
}
|
|
left = true;
|
|
} else if (from == MARIO_RIGHT_SIDE_DETECT) {
|
|
if (!left && !right) {
|
|
movement_blockage = obj.getPos();
|
|
}
|
|
right = true;
|
|
} else if (from == MARIO_TOP_DETECT) {
|
|
top_hit = true;
|
|
} else if (from == MARIO_TOP_LEFT_DETECT ||
|
|
from == MARIO_TOP_RIGHT_DETECT) {
|
|
rightleftpos = obj.getPos();
|
|
top_left_right = true;
|
|
}
|
|
break;
|
|
case DEATH_ID:
|
|
_death = true;
|
|
break;
|
|
case GOOMBA_ID:
|
|
if (from != MARIO_FLOOR_DETECT && from != MARIO_ENEMY_DETECT) {
|
|
_death = true;
|
|
} else if (from == MARIO_FLOOR_DETECT || from == MARIO_ENEMY_DETECT) {
|
|
_bounce = true;
|
|
}
|
|
break;
|
|
case STOP_MOVEMENT:
|
|
stop = true;
|
|
newX = obj.getDoubleRect().first.getX() +
|
|
obj.getDoubleRect().second.getX();
|
|
break;
|
|
case MUSHROOM_ID:
|
|
mushroom = true;
|
|
break;
|
|
case POLE_BOTTOM_ID:
|
|
case POLE_TOP_ID:
|
|
case FLAG_ID:
|
|
_end = true;
|
|
endPos = obj.getPos();
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|