2021-04-25 20:42:55 +00:00
|
|
|
#include "blocks.hpp"
|
|
|
|
#include "global_vars.hpp"
|
|
|
|
#include "objectids.hpp"
|
|
|
|
#include "sprites.hpp"
|
2021-05-08 22:43:53 +00:00
|
|
|
#include "editor_visitor.hpp"
|
2021-04-30 07:10:58 +00:00
|
|
|
#include <unordered_map>
|
2021-05-25 10:26:04 +00:00
|
|
|
#include "mario_visitor.hpp"
|
2021-04-30 07:10:58 +00:00
|
|
|
|
2021-05-08 22:46:10 +00:00
|
|
|
MarioBlock::MarioBlock( int x, int y,
|
|
|
|
std::shared_ptr< SDLPP::Renderer > renderer,
|
|
|
|
std::shared_ptr< SDLPP::Texture > texture,
|
2021-05-23 22:07:40 +00:00
|
|
|
SDL_Rect src, bool destructible )
|
2021-05-08 22:46:10 +00:00
|
|
|
: RectangleRender( x * BLOCK_SIZE, 1 - ( 16 - y ) * BLOCK_SIZE,
|
2021-05-23 22:07:40 +00:00
|
|
|
BLOCK_SIZE, BLOCK_SIZE, renderer, texture, src ) {
|
|
|
|
_destructible = destructible;
|
2021-05-25 20:05:50 +00:00
|
|
|
setMovementSpeed(1);
|
2021-05-23 22:07:40 +00:00
|
|
|
}
|
2021-05-02 12:14:11 +00:00
|
|
|
void MarioBlock::visit( SDLPP::Visitor &visitor ) {
|
2021-05-25 14:34:44 +00:00
|
|
|
#ifdef EDITOR
|
2021-05-08 22:46:10 +00:00
|
|
|
if ( !_tool && _terrain &&
|
|
|
|
visitor.getVisitorType() == VisitorType::Terrain ) {
|
2021-05-07 21:17:05 +00:00
|
|
|
destroy();
|
|
|
|
}
|
2021-05-08 22:46:10 +00:00
|
|
|
if ( !_tool && !_terrain &&
|
|
|
|
visitor.getVisitorType() == VisitorType::Modifier ) {
|
2021-05-02 12:14:11 +00:00
|
|
|
destroy();
|
|
|
|
}
|
2021-05-25 14:34:44 +00:00
|
|
|
#else
|
2021-05-25 20:05:50 +00:00
|
|
|
if(visitor.getFromId() == MARIO_TOP_DETECT && dynamic_cast<MarioVisitor&>(visitor).canDestroy()) {
|
|
|
|
if( _destructible ) {
|
|
|
|
destroy();
|
|
|
|
} else {
|
2021-05-26 16:24:09 +00:00
|
|
|
BounceVisitor bv;
|
|
|
|
bv.setVisitorType(VisitorType::Terrain);
|
|
|
|
|
|
|
|
setPos(getPos() - SDLPP::Vec2D<double>(0, BLOCK_SIZE));
|
|
|
|
if(getCollisions().size() < 2)
|
|
|
|
addCollision(SDLPP::RectColider(0.1, 0.1, 0.8, 0.8, 69));
|
|
|
|
updateSizeAndPosition();
|
|
|
|
g_playground->visitCollisions(*this, bv);
|
|
|
|
setPos(getPos() + SDLPP::Vec2D<double>(0, BLOCK_SIZE));
|
|
|
|
updateSizeAndPosition();
|
|
|
|
if(bv.canBounce())
|
|
|
|
bounce();
|
2021-05-25 20:05:50 +00:00
|
|
|
}
|
2021-05-23 22:07:40 +00:00
|
|
|
}
|
2021-05-25 14:34:44 +00:00
|
|
|
#endif
|
2021-05-08 22:46:10 +00:00
|
|
|
visitor.visit( *this );
|
2021-05-02 12:14:11 +00:00
|
|
|
}
|
2021-05-08 22:46:10 +00:00
|
|
|
void MarioBlock::setTool( bool tool ) {
|
2021-05-02 12:14:11 +00:00
|
|
|
_tool = tool;
|
|
|
|
}
|
2021-05-08 22:46:10 +00:00
|
|
|
void MarioBlock::setTerrain( bool terrain ) {
|
2021-05-07 21:17:05 +00:00
|
|
|
_terrain = terrain;
|
2021-05-02 12:43:15 +00:00
|
|
|
}
|
2021-05-02 12:14:11 +00:00
|
|
|
|
2021-05-25 20:05:50 +00:00
|
|
|
void MarioBlock::bounce() {
|
|
|
|
if(_bouncing)
|
|
|
|
return;
|
|
|
|
_bouncing = true;
|
|
|
|
og_pos = getPos();
|
|
|
|
setMovement(0, -0.5);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MarioBlock::custom_move(int ticks) {
|
|
|
|
if(!_bouncing)
|
|
|
|
return;
|
|
|
|
if(getMovement().getY() < 0) {
|
|
|
|
ticks_to_bounce -= ticks;
|
|
|
|
if(ticks_to_bounce < 0) {
|
|
|
|
setMovement(0, 0.5);
|
|
|
|
ticks_to_bounce = bounce_ticks;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if(getPos().getY() >= og_pos.getY()) {
|
|
|
|
setMovement(0, 0);
|
2021-05-26 07:29:12 +00:00
|
|
|
setPos(getPos().getX(), og_pos.getY());
|
2021-05-25 20:05:50 +00:00
|
|
|
_bouncing = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-31 12:03:11 +00:00
|
|
|
void MarioBlock::setType(LandType::Value type) {
|
|
|
|
_type = type;
|
|
|
|
}
|
|
|
|
LandType::Value MarioBlock::getType() const {
|
|
|
|
return _type;
|
|
|
|
}
|
|
|
|
|
2021-05-08 22:46:10 +00:00
|
|
|
const std::vector< uint64_t > possibleBlocks = {
|
|
|
|
FLOOR_ID,
|
|
|
|
STEP_ID,
|
|
|
|
HILL_TOP_ID,
|
|
|
|
HILL_DOTS_LEFT_ID,
|
|
|
|
HILL_FILL_ID,
|
|
|
|
HILL_INCLINE_ID,
|
|
|
|
HILL_DOTS_RIGHT_ID,
|
|
|
|
HILL_DECLINE_ID,
|
|
|
|
CLOUD_LEFT_TOP_ID,
|
|
|
|
CLOUD_MIDDLE_TOP_ID,
|
|
|
|
CLOUD_RIGHT_TOP_ID,
|
|
|
|
VINE_TOP_ID,
|
|
|
|
CLOUD_LEFT_BOTTOM_ID,
|
|
|
|
CLOUD_MIDDLE_BOTTOM_ID,
|
|
|
|
CLOUD_RIGHT_BOTTOM_ID,
|
|
|
|
VINE_BOTTOM_ID,
|
|
|
|
BRICK_TOP_ID,
|
|
|
|
BRICK_ID,
|
|
|
|
FLAG_ID,
|
|
|
|
WATER_TOP_ID,
|
|
|
|
BUSH_LEFT_ID,
|
|
|
|
BUSH_MIDDLE_ID,
|
|
|
|
BUSH_RIGHT_ID,
|
|
|
|
WATER_FILL_ID,
|
|
|
|
PIPE_LEFT_TOP_ID,
|
|
|
|
PIPE_RIGHT_TOP_ID,
|
|
|
|
CASTLE_TOWER_ID,
|
|
|
|
CASTLE_TOWER_FILLED_ID,
|
|
|
|
PIPE_LEFT_BOTTOM_ID,
|
|
|
|
PIPE_RIGHT_BOTTOM_ID,
|
|
|
|
CASTLE_LEFT_ID,
|
|
|
|
CASTLE_RIGHT_ID,
|
|
|
|
POLE_TOP_ID,
|
|
|
|
CASTLE_ENTRY_ID,
|
|
|
|
SIDEWAY_PIPE_END_TOP_ID,
|
|
|
|
SIDEWAY_PIPE_MIDDLE_TOP_ID,
|
|
|
|
POLE_BOTTOM_ID,
|
|
|
|
CASTLE_BLACK_ID,
|
|
|
|
SIDEWAY_PIPE_END_BOTTOM_ID,
|
|
|
|
SIDEWAY_PIPE_MIDDLE_BOTTOM_ID,
|
|
|
|
SIDEWAY_PIPE_CONNECTOR_TOP_ID,
|
|
|
|
TREE_PLATFORM_TOP_LEFT_ID,
|
|
|
|
TREE_PLATFORM_TOP_MIDDLE_ID,
|
|
|
|
TREE_PLATFORM_TOP_RIGHT_ID,
|
|
|
|
SIDEWAY_PIPE_CONNECTOR_BOTTOM_ID,
|
|
|
|
MUSHROOM_PLATFORM_TOP_LEFT_ID,
|
|
|
|
MUSHROOM_PLATFORM_TOP_MIDDLE_ID,
|
|
|
|
MUSHROOM_PLATFORM_TOP_RIGHT_ID,
|
|
|
|
TREE_PLATFORM_BARK_ID,
|
|
|
|
MUSHROOM_PLATFORM_BARK_TOP_ID,
|
|
|
|
TREE_LEAVES_TOP_ID,
|
|
|
|
TREE_LEAVES_SMALL_ID,
|
|
|
|
CANNON_TOWER_ID,
|
|
|
|
MUSHROOM_PLATFORM_BARK_BOTTOM_ID,
|
|
|
|
TREE_LEAVES_BOTTOM_ID,
|
|
|
|
TREE_BARK_ID,
|
|
|
|
CANNON_PEDESTAL_ID,
|
|
|
|
CANNON_ID,
|
2021-05-28 17:51:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const std::vector< uint64_t > possibleMods = {
|
2021-05-25 22:46:19 +00:00
|
|
|
DESTRUCTIBLE_ID,
|
2021-05-07 21:17:05 +00:00
|
|
|
};
|
2021-04-30 07:10:58 +00:00
|
|
|
|
2021-05-28 17:51:02 +00:00
|
|
|
const std::vector< uint64_t > possibleCharacters = {
|
|
|
|
MARIO_ID,
|
|
|
|
};
|
|
|
|
|
2021-05-31 12:03:11 +00:00
|
|
|
const std::vector< LandType::Value > possibleLands = {
|
|
|
|
LandType::OVERWORLD,
|
|
|
|
LandType::UNDERWORLD,
|
|
|
|
LandType::WATER,
|
|
|
|
LandType::BOWSER
|
|
|
|
};
|
|
|
|
|
2021-05-08 22:46:10 +00:00
|
|
|
const std::unordered_map< uint64_t, const SDL_Rect * > block_mapping = {
|
|
|
|
{ FLOOR_ID, &FLOOR_SRC },
|
|
|
|
{ HILL_INCLINE_ID, &HILL_INCLINE_SRC },
|
|
|
|
{ HILL_DECLINE_ID, &HILL_DECLINE_SRC },
|
|
|
|
{ HILL_DOTS_RIGHT_ID, &HILL_DOTS_RIGHT_SRC },
|
|
|
|
{ HILL_DOTS_LEFT_ID, &HILL_DOTS_LEFT_SRC },
|
|
|
|
{ HILL_FILL_ID, &HILL_FILL_SRC },
|
|
|
|
{ HILL_TOP_ID, &HILL_TOP_SRC },
|
|
|
|
{ BUSH_LEFT_ID, &BUSH_LEFT_SRC },
|
|
|
|
{ BUSH_MIDDLE_ID, &BUSH_MIDDLE_SRC },
|
|
|
|
{ BUSH_RIGHT_ID, &BUSH_RIGHT_SRC },
|
|
|
|
{ CLOUD_LEFT_BOTTOM_ID, &CLOUD_LEFT_BOTTOM_SRC },
|
|
|
|
{ CLOUD_MIDDLE_BOTTOM_ID, &CLOUD_MIDDLE_BOTTOM_SRC },
|
|
|
|
{ CLOUD_RIGHT_BOTTOM_ID, &CLOUD_RIGHT_BOTTOM_SRC },
|
|
|
|
{ CLOUD_LEFT_TOP_ID, &CLOUD_LEFT_TOP_SRC },
|
|
|
|
{ CLOUD_MIDDLE_TOP_ID, &CLOUD_MIDDLE_TOP_SRC },
|
|
|
|
{ CLOUD_RIGHT_TOP_ID, &CLOUD_RIGHT_TOP_SRC },
|
|
|
|
{ PIPE_LEFT_BOTTOM_ID, &PIPE_LEFT_BOTTOM_SRC },
|
|
|
|
{ PIPE_LEFT_TOP_ID, &PIPE_LEFT_TOP_SRC },
|
|
|
|
{ PIPE_RIGHT_BOTTOM_ID, &PIPE_RIGHT_BOTTOM_SRC },
|
|
|
|
{ PIPE_RIGHT_TOP_ID, &PIPE_RIGHT_TOP_SRC },
|
|
|
|
{ CASTLE_LEFT_ID, &CASTLE_LEFT_SRC },
|
|
|
|
{ CASTLE_RIGHT_ID, &CASTLE_RIGHT_SRC },
|
|
|
|
{ CASTLE_BLACK_ID, &CASTLE_BLACK_SRC },
|
|
|
|
{ CASTLE_ENTRY_ID, &CASTLE_ENTRY_SRC },
|
|
|
|
{ CASTLE_TOWER_ID, &CASTLE_TOWER_SRC },
|
|
|
|
{ CASTLE_TOWER_FILLED_ID, &CASTLE_TOWER_FILLED_SRC },
|
|
|
|
{ VINE_TOP_ID, &VINE_TOP_SRC },
|
|
|
|
{ VINE_BOTTOM_ID, &VINE_BOTTOM_SRC },
|
|
|
|
{ POLE_TOP_ID, &POLE_TOP_SRC },
|
|
|
|
{ POLE_BOTTOM_ID, &POLE_BOTTOM_SRC },
|
|
|
|
{ FLAG_ID, &FLAG_SRC },
|
|
|
|
{ STEP_ID, &STEP_SRC },
|
|
|
|
{ BRICK_ID, &BRICK_SRC },
|
|
|
|
{ BRICK_TOP_ID, &BRICK_TOP_SRC },
|
|
|
|
{ SIDEWAY_PIPE_END_TOP_ID, &SIDEWAY_PIPE_END_TOP_SRC },
|
|
|
|
{ SIDEWAY_PIPE_END_BOTTOM_ID, &SIDEWAY_PIPE_END_BOTTOM_SRC },
|
|
|
|
{ SIDEWAY_PIPE_MIDDLE_TOP_ID, &SIDEWAY_PIPE_MIDDLE_TOP_SRC },
|
|
|
|
{ SIDEWAY_PIPE_MIDDLE_BOTTOM_ID, &SIDEWAY_PIPE_MIDDLE_BOTTOM_SRC },
|
|
|
|
{ SIDEWAY_PIPE_CONNECTOR_TOP_ID, &SIDEWAY_PIPE_CONNECTOR_TOP_SRC },
|
|
|
|
{ SIDEWAY_PIPE_CONNECTOR_BOTTOM_ID, &SIDEWAY_PIPE_CONNECTOR_BOTTOM_SRC },
|
|
|
|
{ TREE_PLATFORM_TOP_LEFT_ID, &TREE_PLATFORM_TOP_LEFT_SRC },
|
|
|
|
{ TREE_PLATFORM_TOP_MIDDLE_ID, &TREE_PLATFORM_TOP_MIDDLE_SRC },
|
|
|
|
{ TREE_PLATFORM_TOP_RIGHT_ID, &TREE_PLATFORM_TOP_RIGHT_SRC },
|
|
|
|
{ TREE_PLATFORM_BARK_ID, &TREE_PLATFORM_BARK_SRC },
|
|
|
|
{ WATER_TOP_ID, &WATER_TOP_SRC },
|
|
|
|
{ WATER_FILL_ID, &WATER_FILL_SRC },
|
|
|
|
{ MUSHROOM_PLATFORM_TOP_LEFT_ID, &MUSHROOM_PLATFORM_TOP_LEFT_SRC },
|
|
|
|
{ MUSHROOM_PLATFORM_TOP_MIDDLE_ID, &MUSHROOM_PLATFORM_TOP_MIDDLE_SRC },
|
|
|
|
{ MUSHROOM_PLATFORM_TOP_RIGHT_ID, &MUSHROOM_PLATFORM_TOP_RIGHT_SRC },
|
|
|
|
{ MUSHROOM_PLATFORM_BARK_TOP_ID, &MUSHROOM_PLATFORM_BARK_TOP_SRC },
|
|
|
|
{ MUSHROOM_PLATFORM_BARK_BOTTOM_ID, &MUSHROOM_PLATFORM_BARK_BOTTOM_SRC },
|
|
|
|
{ TREE_BARK_ID, &TREE_BARK_SRC },
|
|
|
|
{ TREE_LEAVES_SMALL_ID, &TREE_LEAVES_SMALL_SRC },
|
|
|
|
{ TREE_LEAVES_TOP_ID, &TREE_LEAVES_TOP_SRC },
|
|
|
|
{ TREE_LEAVES_BOTTOM_ID, &TREE_LEAVES_BOTTOM_SRC },
|
|
|
|
{ CANNON_TOWER_ID, &CANNON_TOWER_SRC },
|
|
|
|
{ CANNON_PEDESTAL_ID, &CANNON_PEDESTAL_SRC },
|
|
|
|
{ CANNON_ID, &CANNON_SRC },
|
2021-05-25 22:46:19 +00:00
|
|
|
{ MARIO_ID, &MARIO_STANDING_SRC },
|
|
|
|
{ DESTRUCTIBLE_ID, &DESTRUCTIBLE_SRC },
|
2021-04-30 07:10:58 +00:00
|
|
|
};
|
2021-04-25 20:42:55 +00:00
|
|
|
|
|
|
|
std::shared_ptr< SDLPP::RectangleRender >
|
2021-05-02 12:14:11 +00:00
|
|
|
createBlock( std::shared_ptr< SDLPP::Renderer > &renderer, int x, int y,
|
2021-04-25 20:42:55 +00:00
|
|
|
std::shared_ptr< SDLPP::Texture > &texture, const SDL_Rect &src,
|
2021-05-31 14:07:55 +00:00
|
|
|
uint64_t id, LandType::Value land_type, bool collision = false, bool destructible = false ) {
|
2021-05-23 22:07:40 +00:00
|
|
|
auto block = std::make_shared< MarioBlock >( x, y, renderer, texture, src, destructible );
|
2021-04-25 20:42:55 +00:00
|
|
|
block->setId( id );
|
2021-04-27 13:56:13 +00:00
|
|
|
block->setAlignment( SDLPP::OBJ_CENTER, SDLPP::OBJ_CENTER );
|
2021-04-25 20:42:55 +00:00
|
|
|
block->setStatic();
|
2021-05-31 14:07:55 +00:00
|
|
|
block->setType(land_type);
|
2021-04-25 20:42:55 +00:00
|
|
|
if ( collision )
|
|
|
|
block->addCollision( SDLPP::RectColider( 0, 0, 1, 1 ) );
|
|
|
|
return block;
|
|
|
|
}
|
|
|
|
|
2021-05-08 22:43:53 +00:00
|
|
|
SDL_Rect getSourceRectByID( uint64_t id, LandType::Value type ) {
|
2021-05-08 22:46:10 +00:00
|
|
|
if ( block_mapping.find( id ) == block_mapping.end() )
|
2021-04-30 07:10:58 +00:00
|
|
|
return {};
|
2021-05-08 22:46:10 +00:00
|
|
|
SDL_Rect ret_src = *block_mapping.at( id );
|
2021-04-30 07:10:58 +00:00
|
|
|
switch ( type ) {
|
2021-05-08 22:43:53 +00:00
|
|
|
case LandType::OVERWORLD:
|
2021-04-30 07:10:58 +00:00
|
|
|
ret_src.x += OVERWORLD_SHIFT.getX();
|
|
|
|
ret_src.y += OVERWORLD_SHIFT.getY();
|
|
|
|
break;
|
2021-05-08 22:43:53 +00:00
|
|
|
case LandType::UNDERWORLD:
|
2021-04-30 07:10:58 +00:00
|
|
|
ret_src.x += UNDERWORLD_SHIFT.getX();
|
|
|
|
ret_src.y += UNDERWORLD_SHIFT.getY();
|
|
|
|
break;
|
2021-05-08 22:43:53 +00:00
|
|
|
case LandType::WATER:
|
2021-04-30 07:10:58 +00:00
|
|
|
ret_src.x += WATER_SHIFT.getX();
|
|
|
|
ret_src.y += WATER_SHIFT.getY();
|
|
|
|
break;
|
2021-05-08 22:43:53 +00:00
|
|
|
case LandType::BOWSER:
|
2021-04-30 07:10:58 +00:00
|
|
|
ret_src.x += BOWSER_SHIFT.getX();
|
|
|
|
ret_src.y += BOWSER_SHIFT.getY();
|
|
|
|
break;
|
2021-04-25 20:42:55 +00:00
|
|
|
}
|
2021-04-30 07:10:58 +00:00
|
|
|
return ret_src;
|
2021-04-25 20:42:55 +00:00
|
|
|
}
|
2021-05-08 22:46:10 +00:00
|
|
|
std::shared_ptr< SDLPP::RectangleRender >
|
|
|
|
createTerrainBlock( uint64_t block_id, LandType::Value type,
|
|
|
|
std::shared_ptr< SDLPP::Renderer > &renderer, int x, int y,
|
|
|
|
std::shared_ptr< SDLPP::Texture > texture,
|
2021-05-23 22:07:40 +00:00
|
|
|
bool collision, bool destructible ) {
|
2021-05-01 19:55:43 +00:00
|
|
|
return createBlock( renderer, x, y, texture,
|
2021-05-31 14:07:55 +00:00
|
|
|
getSourceRectByID( block_id, type ), block_id, type,
|
2021-05-23 22:07:40 +00:00
|
|
|
collision, destructible );
|
2021-05-01 19:55:43 +00:00
|
|
|
}
|
2021-05-08 22:46:10 +00:00
|
|
|
std::shared_ptr< SDLPP::RectangleRender >
|
|
|
|
createTerrainBlock( uint64_t block_id, LandType::Value type,
|
|
|
|
std::shared_ptr< SDLPP::Renderer > &renderer,
|
|
|
|
std::shared_ptr< SDLPP::Texture > texture,
|
2021-05-23 22:07:40 +00:00
|
|
|
bool collision, bool destructible ) {
|
2021-05-08 22:46:10 +00:00
|
|
|
return createTerrainBlock( block_id, type, renderer, 0, 0, texture,
|
2021-05-23 22:07:40 +00:00
|
|
|
collision, destructible );
|
2021-05-01 19:55:43 +00:00
|
|
|
}
|
2021-04-25 20:42:55 +00:00
|
|
|
|
2021-04-27 13:56:13 +00:00
|
|
|
std::shared_ptr< SDLPP::RectangleRender >
|
2021-05-08 22:43:53 +00:00
|
|
|
createTerrainBlock( uint64_t block_id, LandType::Value type,
|
2021-05-08 22:46:10 +00:00
|
|
|
std::shared_ptr< SDLPP::Renderer > &renderer, int x, int y,
|
2021-05-23 22:07:40 +00:00
|
|
|
bool collision, bool destructible ) {
|
2021-05-08 22:46:10 +00:00
|
|
|
return createTerrainBlock( block_id, type, renderer, x, y,
|
2021-05-23 22:07:40 +00:00
|
|
|
g_terrain_texture, collision, destructible );
|
2021-04-25 20:42:55 +00:00
|
|
|
}
|
|
|
|
|
2021-04-27 13:56:13 +00:00
|
|
|
std::shared_ptr< SDLPP::RectangleRender >
|
2021-05-08 22:43:53 +00:00
|
|
|
createTerrainBlock( uint64_t block_id, LandType::Value type,
|
2021-04-27 13:56:13 +00:00
|
|
|
std::shared_ptr< SDLPP::Renderer > &renderer,
|
2021-05-23 22:07:40 +00:00
|
|
|
bool collision, bool destructible ) {
|
2021-05-08 22:46:10 +00:00
|
|
|
return createTerrainBlock( block_id, type, renderer, g_terrain_texture,
|
2021-05-23 22:07:40 +00:00
|
|
|
collision, destructible );
|
2021-05-01 19:55:43 +00:00
|
|
|
}
|
|
|
|
|
2021-05-08 22:46:10 +00:00
|
|
|
std::shared_ptr< SDLPP::RectangleRender >
|
|
|
|
createMario( LandType::Value type, std::shared_ptr< SDLPP::Renderer > &renderer,
|
|
|
|
int x, int y ) {
|
|
|
|
// TODO add type additions
|
|
|
|
auto mario = createBlock( renderer, x, y, g_mario_texture,
|
2021-05-31 14:07:55 +00:00
|
|
|
MARIO_STANDING_SRC, MARIO_ID, type, true );
|
2021-05-08 22:46:10 +00:00
|
|
|
dynamic_cast< MarioBlock & >( *mario ).setTerrain( false );
|
2021-05-02 12:43:15 +00:00
|
|
|
return mario;
|
2021-04-25 20:42:55 +00:00
|
|
|
}
|
2021-05-08 22:43:53 +00:00
|
|
|
|
2021-05-08 22:46:10 +00:00
|
|
|
enum BlockRole::Value getBlockRole( uint64_t id ) {
|
|
|
|
if ( id >= 0x7000 )
|
2021-05-08 22:43:53 +00:00
|
|
|
return BlockRole::TERRAIN;
|
2021-05-08 22:46:10 +00:00
|
|
|
if ( id == MARIO_ID )
|
2021-05-08 22:43:53 +00:00
|
|
|
return BlockRole::MARIO;
|
2021-05-25 22:46:19 +00:00
|
|
|
if ( id < MARIO_ID )
|
|
|
|
return BlockRole::MODIFIER;
|
2021-05-08 22:46:10 +00:00
|
|
|
// TODO modifier/character
|
2021-05-08 22:43:53 +00:00
|
|
|
return BlockRole::MODIFIER;
|
|
|
|
}
|