Add coin animation
This commit is contained in:
+17
-2
@@ -3,10 +3,12 @@
|
||||
#include "objectids.hpp"
|
||||
#include "sprites.hpp"
|
||||
#include "editor_visitor.hpp"
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include "mario_visitor.hpp"
|
||||
#include "blocks/simpleblocks.hpp"
|
||||
#include "blocks/coineditorblock.hpp"
|
||||
#include "blocks/coinblock.hpp"
|
||||
#include "mario.hpp"
|
||||
|
||||
#define CAN_BE_DESTROYED_FLAG 0x0000000000000001
|
||||
@@ -57,7 +59,11 @@ void MarioBlock::visit( SDLPP::Visitor &visitor ) {
|
||||
}
|
||||
if ( hasCoin() ) {
|
||||
removeCoin();
|
||||
auto coin = createTerrainBlock(COIN_ID, LandType::OVERWORLD, renderer);
|
||||
coin->setPos(getPos());
|
||||
std::dynamic_pointer_cast<CoinBlock>(coin)->setParent(this);
|
||||
dynamic_cast< MarioVisitor & >( visitor ).setCoin();
|
||||
dynamic_cast< MarioVisitor & >( visitor ).setCoinBlock(coin);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -75,7 +81,12 @@ void MarioBlock::bounce() {
|
||||
return;
|
||||
_bouncing = true;
|
||||
og_pos = getPos();
|
||||
setMovement( 0, -0.5 );
|
||||
ticks_to_bounce = bounce_ticks;
|
||||
setMovement( 0, -bounce_speed );
|
||||
}
|
||||
|
||||
bool MarioBlock::isBouncing() {
|
||||
return _bouncing;
|
||||
}
|
||||
|
||||
void MarioBlock::custom_move( int ticks ) {
|
||||
@@ -84,7 +95,7 @@ void MarioBlock::custom_move( int ticks ) {
|
||||
if ( getMovement().getY() < 0 ) {
|
||||
ticks_to_bounce -= ticks;
|
||||
if ( ticks_to_bounce < 0 ) {
|
||||
setMovement( 0, 0.5 );
|
||||
setMovement( 0, bounce_speed );
|
||||
ticks_to_bounce = bounce_ticks;
|
||||
}
|
||||
} else {
|
||||
@@ -491,6 +502,10 @@ createBlockById( uint64_t id, int x, int y,
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< MushroomModifierBlock >( x, y, renderer ) );
|
||||
break;
|
||||
case COIN_ID:
|
||||
result = std::static_pointer_cast< MarioBlock >(
|
||||
std::make_shared< CoinBlock >( x, y, renderer ) );
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user