From 9fd43d1d3a7642b10f2f30bb65af7e86aaf77b29 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Sun, 3 Mar 2013 21:28:12 +0100 Subject: [PATCH] Fixed bullet collisions. --- source/effects/Bullet.cpp | 10 +++++----- source/effects/Bullet.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/source/effects/Bullet.cpp b/source/effects/Bullet.cpp index 6038d7e..9b646fa 100755 --- a/source/effects/Bullet.cpp +++ b/source/effects/Bullet.cpp @@ -27,7 +27,7 @@ const float Bullet::DEFAULT_SPEED = 500; */ Bullet::Bullet(const sf::Vector2f& position, Sprite& shooter, float direction, const Yaml& config) : - Particle(config, Data(position, 0, CATEGORY_PARTICLE, CATEGORY_PARTICLE)), + Particle(config, Data(position, 0, CATEGORY_PARTICLE, ~CATEGORY_PARTICLE)), mShooter(shooter), mDamage(config.get(KEY_DAMAGE, DEFAULT_DAMAGE)), mSpeed(config.get(KEY_SPEED, DEFAULT_SPEED)) { @@ -41,13 +41,13 @@ Bullet::Bullet(const sf::Vector2f& position, Sprite& shooter, float direction, * @copydoc Physical::onCollide */ void -Bullet::onCollide(Sprite& other) { +Bullet::onCollide(std::shared_ptr other) { // Make sure we do not damage twice. if (!getDelete()) { // Call onShot on other, with damage as param. - if (other.getCategory() == CATEGORY_ACTOR) { - Character& a = dynamic_cast(other); - a.onDamage(mDamage); + if (other->getCategory() == CATEGORY_ACTOR) { + std::shared_ptr character = std::static_pointer_cast(other); + character->onDamage(mDamage); } setDelete(true); } diff --git a/source/effects/Bullet.h b/source/effects/Bullet.h index 4a77f46..3a70a0e 100755 --- a/source/effects/Bullet.h +++ b/source/effects/Bullet.h @@ -25,7 +25,7 @@ public: Bullet(const sf::Vector2f& position, Sprite& shooter, float direction, const Yaml& config); - void onCollide(Sprite& other); + void onCollide(std::shared_ptr other); // Private variables. private: