Mario: prepartations for multiple moving objects

This commit is contained in:
2021-08-05 00:32:17 +02:00
parent 37f7bab63e
commit bfe658618e
19 changed files with 321 additions and 249 deletions
+6 -6
View File
@@ -7,7 +7,7 @@ CoinEditorBlock::CoinEditorBlock( int x, int y,
false, false ) {
setId( COIN_MODIFIER_ID );
auto mypos = getDoubleRect();
auto size = mypos.second.getX() / 1.5;
auto size = mypos.second.getX() / size_divisor;
_amount_text = std::make_shared< SDLPP::TextRenderer >(
mypos.first.getX() + mypos.second.getX() - size,
mypos.first.getY() + mypos.second.getX() - size, size, size, renderer,
@@ -18,7 +18,7 @@ CoinEditorBlock::CoinEditorBlock( int x, int y,
void CoinEditorBlock::render() {
MarioBlock::render();
if ( _amount_text != NULL && !hidden ) {
if ( _amount_text != nullptr && !hidden ) {
_amount_text->render();
}
}
@@ -26,12 +26,12 @@ void CoinEditorBlock::render() {
void CoinEditorBlock::updateSizeAndPosition() {
MarioBlock::updateSizeAndPosition();
auto block_size = getDoubleRect().second;
_amount_text->setPos( getPos() + block_size - block_size / 1.5 );
_amount_text->setPos( getPos() + block_size - block_size / size_divisor );
_amount_text->updateSizeAndPosition();
}
void CoinEditorBlock::addOne() {
if ( _amount < 15 ) {
if ( _amount < max_amount ) {
_amount++;
updateText();
}
@@ -47,8 +47,8 @@ void CoinEditorBlock::subtractOne() {
void CoinEditorBlock::setAmount( int amount ) {
if ( amount < 1 ) {
amount = 1;
} else if ( amount > 15 ) {
amount = 15;
} else if ( amount > max_amount ) {
amount = max_amount;
}
_amount = amount;
updateText();