RType
SpriteComponent.hpp
Go to the documentation of this file.
1 /*
2 ** EPITECH PROJECT, 2023
3 ** R-type
4 ** File description:
5 ** R-type
6 */
7 
8 #pragma once
9 
10 #include "Components/AComponent.hpp"
11 #include <SFML/Graphics.hpp>
12 
14 {
15  public:
16 
17  /**
18  * @brief Construct a new Sprite Component:: Sprite Component object
19  *
20  * @param core
21  * @param socket
22  */
23  explicit SpriteComponent(ClientCore *core, std::shared_ptr<ClientSocket> socket);
24 
25  /**
26  * @brief Destroy the Sprite Component:: Sprite Component object
27  *
28  */
29  ~SpriteComponent() override = default;
30 
31  /**
32  * @brief action
33  *
34  */
35  void action() override;
36 
37  /**
38  * @brief setTexture, set the texture
39  *
40  * @param texture
41  */
42  void setTexture(const sf::Texture &texture);
43 
44  /**
45  * @brief setPosition, set the position
46  *
47  * @param position
48  */
49  void setPosition(sf::Vector2f position);
50 
51  /**
52  * @brief setPosition, set the position
53  *
54  * @param x
55  * @param y
56  */
57  void setPosition(float x, float y);
58 
59  /**
60  * @brief setSize, set the size
61  *
62  * @param size
63  */
64  void setSize(sf::Vector2f size);
65 
66  /**
67  * @brief setRect, set the rect
68  *
69  * @param rect
70  */
71  void setRect(sf::IntRect rect);
72 
73  /**
74  * @brief display, display the sprite
75  *
76  * @param window
77  */
78  void display(sf::RenderWindow &window) override;
79 
80  /**
81  * @brief handleEvent, handle the event
82  *
83  * @param event
84  * @param window
85  */
86  void handleEvent(const sf::Event &event, sf::RenderWindow &window) override;
87 
88  private:
89  sf::Texture _texture;
90  sf::Sprite _sprite;
91  sf::Vector2f _position;
92  sf::Vector2f _size;
93  sf::IntRect _rect;
94  std::shared_ptr<ClientSocket> _socket;
95 };