From 26cbdd0f8e4411bf27ec660e5fd25a07f7b5fb44 Mon Sep 17 00:00:00 2001 From: zvon Date: Mon, 31 May 2021 16:07:55 +0200 Subject: [PATCH] Mario: add block's land type when creating block --- mario/blocks.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mario/blocks.cpp b/mario/blocks.cpp index 2e6a984..1074209 100644 --- a/mario/blocks.cpp +++ b/mario/blocks.cpp @@ -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; }