diff --git a/include/simpleengine/components/hitbox_component.h b/include/simpleengine/components/hitbox_component.h index 4745c95..f52694d 100644 --- a/include/simpleengine/components/hitbox_component.h +++ b/include/simpleengine/components/hitbox_component.h @@ -23,6 +23,8 @@ namespace simpleengine { HitboxComponent(Entity& owning_entity, sf::Sprite& sprite, float sprite_offset_x, float sprite_offset_y, float width, float height); + sf::RectangleShape& GetHitbox() const; + bool DoesIntersect(const sf::FloatRect& rect); void Update(const float &delta_time) override; diff --git a/src/components/hitbox_component.cpp b/src/components/hitbox_component.cpp index d541637..e55e89c 100644 --- a/src/components/hitbox_component.cpp +++ b/src/components/hitbox_component.cpp @@ -8,8 +8,6 @@ #include "components/ssma_component.h" #include "entity.h" -#include - simpleengine::HitboxComponent::HitboxComponent(Entity& owning_entity, sf::Sprite &sprite, float sprite_offset_x, float sprite_offset_y, float width, float height) : Component(owning_entity), sprite(sprite), offset_x(sprite_offset_x), offset_y(sprite_offset_y) { @@ -26,6 +24,10 @@ simpleengine::HitboxComponent::HitboxComponent(Entity& owning_entity, sf::Sprite } } +sf::RectangleShape &simpleengine::HitboxComponent::GetHitbox() const { + return hitbox; +} + bool simpleengine::HitboxComponent::DoesIntersect(const sf::FloatRect &rect) { return hitbox.getGlobalBounds().intersects(rect); }