Skip to content

Commit

Permalink
Fix bug with thrown objects interacting with coins.
Browse files Browse the repository at this point in the history
  • Loading branch information
martinvanzijl committed Jun 23, 2020
1 parent 5becda3 commit d700f88
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/object/rock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include "audio/sound_manager.hpp"
#include "object/explosion.hpp"
#include "object/coin.hpp"
#include "badguy/badguy.hpp"
#include "object/player.hpp"
#include "supertux/sector.hpp"
#include "supertux/tile.hpp"
#include "util/reader_mapping.hpp"
Expand Down Expand Up @@ -129,9 +131,13 @@ Rock::collision(GameObject& other, const CollisionHit& hit)
if (hit.bottom && physic.get_velocity_y() > 200) {
auto moving_object = dynamic_cast<MovingObject*> (&other);
if (moving_object) {
//Getting a rock on the head hurts. A lot.
moving_object->collision_tile(Tile::HURTS);
physic.set_velocity_y(0);
auto badguy = dynamic_cast<BadGuy*> (moving_object);
auto player = dynamic_cast<Player*> (moving_object);
if (badguy || player) {
//Getting a rock on the head hurts. A lot.
moving_object->collision_tile(Tile::HURTS);
physic.set_velocity_y(0);
}
}
}
return FORCE_MOVE;
Expand Down

0 comments on commit d700f88

Please sign in to comment.