From 65575702d9e11d722054533f6d74953c06d6c4ab Mon Sep 17 00:00:00 2001 From: SeanOMik Date: Sun, 12 Jul 2020 22:41:59 -0500 Subject: [PATCH] Add `HitboxComponent::GetHitbox` --- include/simpleengine/components/hitbox_component.h | 2 ++ src/components/hitbox_component.cpp | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) 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); }