Mario: add block's land type when creating block
This commit is contained in:
parent
808f392119
commit
26cbdd0f8e
@ -229,11 +229,12 @@ const std::unordered_map< uint64_t, const SDL_Rect * > block_mapping = {
|
||||
std::shared_ptr< SDLPP::RectangleRender >
|
||||
createBlock( std::shared_ptr< SDLPP::Renderer > &renderer, int x, int y,
|
||||
std::shared_ptr< SDLPP::Texture > &texture, const SDL_Rect &src,
|
||||
uint64_t id, bool collision = false, bool destructible = false ) {
|
||||
uint64_t id, LandType::Value land_type, bool collision = false, bool destructible = false ) {
|
||||
auto block = std::make_shared< MarioBlock >( x, y, renderer, texture, src, destructible );
|
||||
block->setId( id );
|
||||
block->setAlignment( SDLPP::OBJ_CENTER, SDLPP::OBJ_CENTER );
|
||||
block->setStatic();
|
||||
block->setType(land_type);
|
||||
if ( collision )
|
||||
block->addCollision( SDLPP::RectColider( 0, 0, 1, 1 ) );
|
||||
return block;
|
||||
@ -269,7 +270,7 @@ createTerrainBlock( uint64_t block_id, LandType::Value type,
|
||||
std::shared_ptr< SDLPP::Texture > texture,
|
||||
bool collision, bool destructible ) {
|
||||
return createBlock( renderer, x, y, texture,
|
||||
getSourceRectByID( block_id, type ), block_id,
|
||||
getSourceRectByID( block_id, type ), block_id, type,
|
||||
collision, destructible );
|
||||
}
|
||||
std::shared_ptr< SDLPP::RectangleRender >
|
||||
@ -302,7 +303,7 @@ 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,
|
||||
MARIO_STANDING_SRC, MARIO_ID, true );
|
||||
MARIO_STANDING_SRC, MARIO_ID, type, true );
|
||||
dynamic_cast< MarioBlock & >( *mario ).setTerrain( false );
|
||||
return mario;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user