game/mario/blocks/coinblock.cpp

27 lines
714 B
C++
Raw Normal View History

2021-07-24 18:50:24 +00:00
#include "coinblock.hpp"
#include "../sprites.hpp"
#include "../global_vars.hpp"
2021-10-18 08:10:43 +00:00
CoinBlock::CoinBlock(int x, int y, std::shared_ptr<SDLPP::Renderer> &renderer)
: MarioBlock(x, y, renderer, g_terrain_texture, COIN_SRC, true, true) {
2021-07-24 18:50:24 +00:00
setHidden(true);
bounce_speed = 0.75;
bounce_ticks = 150;
}
void CoinBlock::custom_move(int ticks) {
2021-10-18 08:10:43 +00:00
if (_parent != nullptr && !_parent->isBouncing() && !isBouncing()) {
2021-07-24 18:50:24 +00:00
setHidden(false);
bounce();
_parent = nullptr;
} else if (_parent == nullptr && !isBouncing()) {
setHidden(true);
destroy();
}
MarioBlock::custom_move(ticks);
}
void CoinBlock::setParent(MarioBlock *parent) {
_parent = parent;
}