R-Type  2
Doom but in better
Loading...
Searching...
No Matches
Bullet.hpp
Go to the documentation of this file.
1/*
2** EPITECH PROJECT, 2024
3** rtype (Workspace)
4** File description:
5** Bullet.hpp
6*/
7
14#pragma once
15#include "Log.hpp"
16#include "Recoded.hpp"
17#include "LogMacros.hpp"
18#include "Utilities.hpp"
21
22namespace GUI
23{
24 namespace ECS
25 {
26 namespace Online
27 {
31 class Bullet : public EntityNode {
32 public:
38 Bullet(const std::uint32_t EntityId = 0);
39
50 Bullet(const GUI::ECS::Components::SpriteComponent &sprite, const bool fromEnemy, const std::pair<int, int> &positionInitial, const unsigned int speed, const std::pair<int, int> &direction = { 0, -1 }, const int damage = 10);
51
57 Bullet(const GUI::ECS::Online::Bullet &bullet);
58
70 Bullet(const std::uint32_t EntityId, const GUI::ECS::Components::SpriteComponent &sprite, const bool fromEnemy, const std::pair<int, int> &positionInitial, const unsigned int speed, const std::pair<int, int> &direction = { 0, -1 }, const int damage = 10);
71
78 Bullet(const std::uint32_t EntityId, const GUI::ECS::Online::Bullet &bullet);
79
83 ~Bullet() = default;
84
90 void setVisible(const bool visible);
91
97 void setPosition(const std::pair<float, float> &pos);
98
105
111 void setEnemy(const bool enemy);
112
118 void setSpeed(const unsigned int speed);
119
125 void setDirection(const std::pair<int, int> &direction);
126
132 void setSize(const std::pair<float, float> &dimension);
133
139 void setDamage(const int damage);
140
144 void tick();
145
152
153 const bool isVisible() const;
154
155 const bool isEnemy() const;
156
157 const std::pair<float, float> getPosition() const;
158
159
160 /*
161 If needed, check the opposite condition, as if<object> was the target and target the object
162 ( = check isColliding as target with bullet as parameter)
163 */
164 const bool isColliding(const GUI::ECS::Systems::Collision &second) const;
165
171 void update(const GUI::ECS::Online::Bullet &copy);
172
181
187 const unsigned int getSpeed() const;
188
195
202
208 const std::pair<int, int> getPositionInitial() const;
209
215 const int getDamage() const;
216
222 const std::pair<int, int> getDirection() const;
223
233 const std::string getInfo(const unsigned int indent = 0) const;
234
235
236 private:
237
243 void _createBullet(const std::pair<int, int> &positionInitial);
244
245 int _damage = 10;
246 bool _visible;
247 bool _fromEnemy;
248 unsigned int _speed;
249 std::pair<int, int> _direction;
250 std::pair<int, int> _positionInitial;
253 };
254
263 std::ostream &operator<<(std::ostream &os, const Bullet &item);
264 }
265 }
266}
This is the file that links the EntityNode children.
Macro definitions for logging messages with varying levels of detail and formatting.
This is the file in charge of containing the Log class (the one in charge of outputing info only when...
This is an agglomerator in which all the files from Recoded folder will be included.
This is the file that contains the class in charge of managing a sprite.
Represents a drawable and interactive sprite in the ECS system.
Represents a bullet entity in the game.
Definition Bullet.hpp:31
void setDirection(const std::pair< int, int > &direction)
Sets the direction of the bullet.
Definition Bullet.cpp:73
const GUI::ECS::Components::SpriteComponent render()
Renders the bullet.
Definition Bullet.cpp:114
void setVisible(const bool visible)
Sets the visibility of the bullet.
Definition Bullet.cpp:46
const std::pair< int, int > getPositionInitial() const
Get the initial position that was set for the object.
Definition Bullet.cpp:217
const int getDamage() const
Get the Damage the bullet will inflict upon impact.
Definition Bullet.cpp:222
const GUI::ECS::Systems::Collision getCollision() const
Get the Collision component.
Definition Bullet.cpp:207
~Bullet()=default
Default destructor for the Bullet class.
void setSprite(const GUI::ECS::Components::SpriteComponent &sprite)
Sets the sprite representing the bullet.
Definition Bullet.cpp:58
const bool isEnemy() const
Definition Bullet.cpp:124
void setDamage(const int damage)
Sets the damage dealt by the bullet.
Definition Bullet.cpp:84
Bullet & operator=(const GUI::ECS::Online::Bullet &copy)
Overloads the assignment operator to copy from another Bullet.
Definition Bullet.cpp:196
Bullet(const std::uint32_t EntityId=0)
Default constructor for the Bullet class.
Definition Bullet.cpp:16
void setEnemy(const bool enemy)
Marks the bullet as fired by an enemy or not.
Definition Bullet.cpp:63
void setPosition(const std::pair< float, float > &pos)
Sets the position of the bullet.
Definition Bullet.cpp:52
const std::string getInfo(const unsigned int indent=0) const
This is a function meant for debugging purposes It will dump the current state of the variables upon ...
Definition Bullet.cpp:232
const GUI::ECS::Components::SpriteComponent getSprite() const
Get the Sprite component.
Definition Bullet.cpp:212
void setSize(const std::pair< float, float > &dimension)
Sets the size of the bullet.
Definition Bullet.cpp:78
const bool isVisible() const
Definition Bullet.cpp:119
const unsigned int getSpeed() const
Get the Speed at which the bullet is traveling.
Definition Bullet.cpp:202
const bool isColliding(const GUI::ECS::Systems::Collision &second) const
Definition Bullet.cpp:139
const std::pair< float, float > getPosition() const
Definition Bullet.cpp:129
const std::pair< int, int > getDirection() const
Get the Direction in which the bullet is travelling.
Definition Bullet.cpp:227
void update(const GUI::ECS::Online::Bullet &copy)
Updates the sprite by copying another Bullet.
Definition Bullet.cpp:176
void setSpeed(const unsigned int speed)
Sets the speed of the bullet.
Definition Bullet.cpp:68
void tick()
Advances the bullet's state by one tick.
Definition Bullet.cpp:89
Represents a rectangular component that can detect collisions and mouse interactions,...
Definition Collision.hpp:39
std::ostream & operator<<(std::ostream &os, const Bullet &item)
Outputs the sprite's info to a stream.
Definition Bullet.cpp:260