Mario: check before bouncing

This commit is contained in:
2021-05-26 18:24:09 +02:00
parent 734b0b58cb
commit 6e61eb03b9
6 changed files with 56 additions and 2 deletions
+12 -2
View File
@@ -30,8 +30,18 @@ void MarioBlock::visit( SDLPP::Visitor &visitor ) {
if( _destructible ) {
destroy();
} else {
// TODO check if anything above
bounce();
BounceVisitor bv;
bv.setVisitorType(VisitorType::Terrain);
setPos(getPos() - SDLPP::Vec2D<double>(0, BLOCK_SIZE));
if(getCollisions().size() < 2)
addCollision(SDLPP::RectColider(0.1, 0.1, 0.8, 0.8, 69));
updateSizeAndPosition();
g_playground->visitCollisions(*this, bv);
setPos(getPos() + SDLPP::Vec2D<double>(0, BLOCK_SIZE));
updateSizeAndPosition();
if(bv.canBounce())
bounce();
}
}
#endif