Add coin animation
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
#include "coinblock.hpp"
|
||||
#include "../sprites.hpp"
|
||||
#include "../global_vars.hpp"
|
||||
|
||||
CoinBlock::CoinBlock( int x, int y, std::shared_ptr< SDLPP::Renderer > renderer ) : MarioBlock(x, y, renderer, g_terrain_texture, COIN_SRC, true, true) {
|
||||
setHidden(true);
|
||||
bounce_speed = 0.75;
|
||||
bounce_ticks = 150;
|
||||
}
|
||||
|
||||
void CoinBlock::custom_move(int ticks) {
|
||||
if(_parent != nullptr && !_parent->isBouncing() && !isBouncing()) {
|
||||
setHidden(false);
|
||||
bounce();
|
||||
_parent = nullptr;
|
||||
} else if (_parent == nullptr && !isBouncing()) {
|
||||
setHidden(true);
|
||||
destroy();
|
||||
}
|
||||
MarioBlock::custom_move(ticks);
|
||||
}
|
||||
|
||||
void CoinBlock::setParent(MarioBlock *parent) {
|
||||
_parent = parent;
|
||||
}
|
||||
Reference in New Issue
Block a user