-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHitboxComponent.h
More file actions
40 lines (27 loc) · 836 Bytes
/
HitboxComponent.h
File metadata and controls
40 lines (27 loc) · 836 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#pragma once
class HitboxComponent
{
private:
//variables:
sf::Sprite& sprite;
sf::RectangleShape hitbox;
sf::FloatRect nextPosition;
float offsetX;
float offsetY;
public:
//Constructors and Destructor:
HitboxComponent(sf::Sprite& sprite, const float offset_x, const float offset_y, const float width, const float height);
virtual ~HitboxComponent();
//Accessors:
const sf::Vector2f& getPosition() const;
const sf::Vector2f getCenter() const;
const sf::FloatRect getGlobalBounds() const;
const sf::FloatRect& getNextPosition(const sf::Vector2f& velocity);
//Modifiers:
void setPosition(const sf::Vector2f& position);
void setPosition(const float x, const float y);
//Functions:
bool intersects(const sf::FloatRect& frect);
void update();
void render(sf::RenderTarget* target, const bool visible = true);
};