game/mario/mario_visitor.cpp

37 lines
1.0 KiB
C++

#include "mario_visitor.hpp"
#include "../sdlpp/sdlpp_renderobject.hpp"
#include "objectids.hpp"
void MarioVisitor::visit( const SDLPP::RenderObject &obj ) {
auto id = obj.getId();
switch ( id ) {
case FLOOR_ID:
case BRICK_ID:
case BRICK_TOP_ID:
if ( from == MARIO_FLOOR_DETECT ) {
onGround = true;
groundY = obj.getPos().getY();
} else if ( from == MARIO_LEFT_SIDE_DETECT ) {
left = true;
} else if (from == MARIO_RIGHT_SIDE_DETECT ) {
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 STOP_MOVEMENT:
stop = true;
newX = obj.getDoubleRect().first.getX() +
obj.getDoubleRect().second.getX();
break;
default:
break;
}
}