2020-07-07 05:52:03 +00:00
|
|
|
//
|
|
|
|
// Created by SeanOMik on 7/6/2020.
|
|
|
|
// Github: https://github.com/SeanOMik
|
|
|
|
// Email: seanomik@gmail.com
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef SIMPLEENGINE_HITBOX_COMPONENT_H
|
|
|
|
#define SIMPLEENGINE_HITBOX_COMPONENT_H
|
|
|
|
|
|
|
|
#include "../component.h"
|
|
|
|
|
|
|
|
#include <SFML/Graphics.hpp>
|
|
|
|
|
|
|
|
namespace simpleengine {
|
|
|
|
class HitboxComponent : public Component {
|
|
|
|
private:
|
|
|
|
sf::Sprite& sprite;
|
|
|
|
sf::RectangleShape hitbox;
|
|
|
|
|
|
|
|
float offset_x;
|
|
|
|
float offset_y;
|
|
|
|
public:
|
|
|
|
HitboxComponent(Entity& owning_entity, sf::Sprite& sprite, float sprite_offset_x, float sprite_offset_y,
|
|
|
|
float width, float height);
|
|
|
|
|
2020-07-13 03:46:27 +00:00
|
|
|
sf::RectangleShape& GetHitbox();
|
2020-07-13 03:41:59 +00:00
|
|
|
|
2020-07-07 05:52:03 +00:00
|
|
|
bool DoesIntersect(const sf::FloatRect& rect);
|
|
|
|
|
|
|
|
void Update(const float &delta_time) override;
|
|
|
|
void Render(sf::RenderTarget *target) override;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif //SIMPLEENGINE_HITBOX_COMPONENT_H
|