Added FEATURE flag, fixed rare segfault
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
#include "custom_classes.hpp"
|
||||
|
||||
std::shared_ptr< SDLPP::Texture > TetrisBlock::block_texture = nullptr;
|
||||
#ifdef FEATURE
|
||||
const std::vector<SDL_Rect> blockanim = {{0,0,125,125}, {125,0,250,125}, {125,125,250,250}, {0,125,125,250}};
|
||||
#endif
|
||||
|
||||
TetrisBlock::TetrisBlock( double x, double y, double w, double h,
|
||||
const std::shared_ptr< SDLPP::Renderer > &r,
|
||||
@@ -13,11 +16,19 @@ TetrisBlock::TetrisBlock( double x, double y, double w, double h,
|
||||
pieces_bag[_index]--;
|
||||
_scene = scene;
|
||||
setColors();
|
||||
if ( TetrisBlock::block_texture == nullptr )
|
||||
if ( TetrisBlock::block_texture == nullptr ) {
|
||||
TetrisBlock::block_texture =
|
||||
std::make_shared< SDLPP::Texture >( renderer, "block.png" );
|
||||
TetrisBlock::block_texture->setAlpha(240);
|
||||
}
|
||||
if ( g_show_3d )
|
||||
#ifdef FEATURE
|
||||
setTexture( TetrisBlock::block_texture, 0, 0, 125, 125 );
|
||||
setAnimationFrames( blockanim );
|
||||
setAnimationSpeed(4);
|
||||
#else
|
||||
setTexture( TetrisBlock::block_texture );
|
||||
#endif
|
||||
}
|
||||
|
||||
TetrisBlock::TetrisBlock( const TetrisBlock &other )
|
||||
@@ -66,7 +77,11 @@ void TetrisBlock::specialAction( int code ) {
|
||||
// fallthrough
|
||||
case PIECE_ACTION_UPDATE_BLOCK:
|
||||
if ( g_show_3d )
|
||||
setTexture( "block.png" );
|
||||
#ifdef FEATURE
|
||||
setTexture( TetrisBlock::block_texture, 0, 0, 125, 125 );
|
||||
#else
|
||||
setTexture( TetrisBlock::block_texture );
|
||||
#endif
|
||||
else
|
||||
unsetTexture();
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user