Add `HitboxComponent::GetHitbox`

This commit is contained in:
SeanOMik 2020-07-12 22:41:59 -05:00
parent 05ae937acf
commit 65575702d9
No known key found for this signature in database
GPG Key ID: FA4D55AC05268A88
2 changed files with 6 additions and 2 deletions

View File

@ -23,6 +23,8 @@ namespace simpleengine {
HitboxComponent(Entity& owning_entity, sf::Sprite& sprite, float sprite_offset_x, float sprite_offset_y, HitboxComponent(Entity& owning_entity, sf::Sprite& sprite, float sprite_offset_x, float sprite_offset_y,
float width, float height); float width, float height);
sf::RectangleShape& GetHitbox() const;
bool DoesIntersect(const sf::FloatRect& rect); bool DoesIntersect(const sf::FloatRect& rect);
void Update(const float &delta_time) override; void Update(const float &delta_time) override;

View File

@ -8,8 +8,6 @@
#include "components/ssma_component.h" #include "components/ssma_component.h"
#include "entity.h" #include "entity.h"
#include <iostream>
simpleengine::HitboxComponent::HitboxComponent(Entity& owning_entity, sf::Sprite &sprite, float sprite_offset_x, float sprite_offset_y, 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) { 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) { bool simpleengine::HitboxComponent::DoesIntersect(const sf::FloatRect &rect) {
return hitbox.getGlobalBounds().intersects(rect); return hitbox.getGlobalBounds().intersects(rect);
} }