Add coin animation

This commit is contained in:
2021-07-24 20:50:24 +02:00
parent 130a01feda
commit e67cf508a2
12 changed files with 89 additions and 14 deletions
+25
View File
@@ -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;
}
+15
View File
@@ -0,0 +1,15 @@
#ifndef COIN_BLOCK_HPP
#define COIN_BLOCK_HPP
#include "../blocks.hpp"
class CoinBlock : public MarioBlock {
public:
CoinBlock( int x, int y, std::shared_ptr< SDLPP::Renderer > renderer );
virtual void custom_move(int ticks) override;
void setParent(MarioBlock *parent);
private:
MarioBlock *_parent;
};
#endif
-4
View File
@@ -444,10 +444,6 @@ BackgroundModifierBlock::BackgroundModifierBlock( int x, int y,
std::shared_ptr< SDLPP::Renderer > renderer ) : MarioBlock (x, y, renderer, g_mod_texture, MOD_BACKGROUND_SRC, false ) {
setId( BACKGROUND_MODIFIER_ID );
}
CoinModifierBlock::CoinModifierBlock( int x, int y,
std::shared_ptr< SDLPP::Renderer > renderer ) : MarioBlock (x, y, renderer, g_mod_texture, MOD_COIN_SRC, false ) {
setId( COIN_MODIFIER_ID );
}
MushroomModifierBlock::MushroomModifierBlock( int x, int y,
std::shared_ptr< SDLPP::Renderer > renderer ) : MarioBlock (x, y, renderer, g_mod_texture, MOD_MUSHROOM_SRC, false ) {
setId( MUSHROOM_MODIFIER_ID );
-5
View File
@@ -290,11 +290,6 @@ public:
BackgroundModifierBlock( int x, int y,
std::shared_ptr< SDLPP::Renderer > renderer );
};
class CoinModifierBlock : public MarioBlock {
public:
CoinModifierBlock( int x, int y,
std::shared_ptr< SDLPP::Renderer > renderer );
};
class MushroomModifierBlock : public MarioBlock {
public:
MushroomModifierBlock( int x, int y,