Mario: mario detects enemies and bounces when he kills them/dies when they kill him
This commit is contained in:
+7
-2
@@ -27,10 +27,10 @@ Mario::Mario(int x, int y, const std::shared_ptr< SDLPP::Renderer > &renderer) :
|
||||
SDLPP::RectColider( 0.9, 0, 0.1, 0.1, MARIO_TOP_LEFT_DETECT ) );
|
||||
top_collision = std::make_shared<SDLPP::RectColider>( 0.5, 0, 0.2, 0.15, MARIO_TOP_DETECT );
|
||||
addCollision( top_collision );
|
||||
addCollision(
|
||||
SDLPP::RectColider( 0, 0, 1, 1, MARIO_ID ) );
|
||||
addCollision( SDLPP::RectColider( 0, 1, 1, 0.2, MARIO_ENEMY_DETECT ) );
|
||||
setColiderColor("#FF0000");
|
||||
setStatic( false );
|
||||
bounce_speed *= 4;
|
||||
}
|
||||
Mario::Mario(const std::shared_ptr< SDLPP::Renderer > &renderer) : Mario(0, 0, renderer) {}
|
||||
void Mario::walkLeft() {
|
||||
@@ -88,6 +88,9 @@ void Mario::handleVisitor(SDLPP::Visitor &visitor) {
|
||||
resetMovementY();
|
||||
stop_jump = true;
|
||||
}
|
||||
if(m_visitor.shouldBounce()) {
|
||||
addMovement(0, -bounce_speed);
|
||||
}
|
||||
// make sure Mario isn't stuck inside a wall
|
||||
// TODO more readable function names
|
||||
if ( m_visitor.isStopped() ) {
|
||||
@@ -129,6 +132,7 @@ void Mario::stopJump() {
|
||||
}
|
||||
|
||||
void Mario::custom_move( int ticks ) {
|
||||
MarioBlock::custom_move(ticks);
|
||||
if(!jumping && on_ground)
|
||||
return;
|
||||
if(getMovement().getY() >= 1.0625 * jump_movement)
|
||||
@@ -155,5 +159,6 @@ void Mario::visit(SDLPP::Visitor &visitor) {
|
||||
}
|
||||
|
||||
void Mario::setWorldTypeSrc(LandType::Value /*UNUSED*/) {
|
||||
MarioBlock::setWorldTypeSrc(LandType::OVERWORLD);
|
||||
// TODO
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user