2021-04-25 20:42:55 +00:00
|
|
|
#include "mario_visitor.hpp"
|
|
|
|
#include "../sdlpp/sdlpp_renderobject.hpp"
|
|
|
|
#include "objectids.hpp"
|
|
|
|
|
|
|
|
void MarioVisitor::visit( const SDLPP::RenderObject &obj ) {
|
|
|
|
auto id = obj.getId();
|
2021-04-26 19:59:21 +00:00
|
|
|
switch ( id ) {
|
2021-04-30 07:10:58 +00:00
|
|
|
case FLOOR_ID:
|
2021-05-23 21:57:29 +00:00
|
|
|
case BRICK_ID:
|
|
|
|
case BRICK_TOP_ID:
|
2021-05-22 20:36:53 +00:00
|
|
|
if ( from == MARIO_FLOOR_DETECT ) {
|
2021-04-25 20:42:55 +00:00
|
|
|
onGround = true;
|
2021-05-22 20:36:53 +00:00
|
|
|
groundY = obj.getPos().getY();
|
|
|
|
} else if ( from == MARIO_LEFT_SIDE_DETECT ) {
|
2021-04-29 10:33:31 +00:00
|
|
|
left = true;
|
2021-05-22 20:36:53 +00:00
|
|
|
} else if (from == MARIO_RIGHT_SIDE_DETECT ) {
|
2021-04-29 10:33:31 +00:00
|
|
|
right = true;
|
2021-05-23 21:57:29 +00:00
|
|
|
} else if (from == MARIO_TOP_DETECT) {
|
|
|
|
top_hit = true;
|
2021-05-25 10:26:04 +00:00
|
|
|
} else if (from == MARIO_TOP_LEFT_DETECT || from == MARIO_TOP_RIGHT_DETECT) {
|
|
|
|
rightleftpos = obj.getPos();
|
|
|
|
top_left_right = true;
|
2021-05-22 20:36:53 +00:00
|
|
|
}
|
2021-04-26 19:59:21 +00:00
|
|
|
break;
|
|
|
|
case DEATH_ID:
|
|
|
|
death = true;
|
|
|
|
break;
|
|
|
|
case STOP_MOVEMENT:
|
|
|
|
stop = true;
|
|
|
|
newX = obj.getDoubleRect().first.getX() +
|
|
|
|
obj.getDoubleRect().second.getX();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2021-04-25 20:42:55 +00:00
|
|
|
}
|
|
|
|
}
|