Simple C++ Game
Components.hpp
1 #pragma once
2 
3 #include <Entity.hpp>
4 
5 #include <SFML/Graphics.hpp>
6 
7 #include <memory>
8 
13 {
14 public:
18  static const std::string RENDER_COMP_ID;
19 
27 
33  std::shared_ptr<sf::Texture> texture;
34 
38  sf::Sprite sprite;
39 };
40 
46 {
47 public:
51  static const std::string LOC_COMP_ID;
52 
60 
64  sf::FloatRect location;
65 };
66 
71 {
72 public:
76  static const std::string VEL_COMP_ID;
77 
84 
88  sf::Vector2f velocity;
89 };
90 
95 {
96 public:
100  static const std::string PLAYER_ID;
101 
106 };
107 
112 {
113 public:
117  static const std::string BALL_ID;
118 
123 };
A component for marking an entity as a ball.
Definition: Components.hpp:112
BallComponent()
Construct a new Ball Component object.
static const std::string BALL_ID
The ID of a BallComponent.
Definition: Components.hpp:117
A component of an entity in the game's component entity system.
Definition: Entity.hpp:27
A component that stores the information about where and how large the entity is.
Definition: Components.hpp:46
sf::FloatRect location
The location and bounds of the entity.
Definition: Components.hpp:64
LocationComponent()
Construct a new Location Component object.
static const std::string LOC_COMP_ID
The ID of LocationComponent.
Definition: Components.hpp:51
A component for marking an entity as a player.
Definition: Components.hpp:95
static const std::string PLAYER_ID
The ID of a PlayerComponent.
Definition: Components.hpp:100
PlayerComponent()
Construct a new Player Component object.
A component that stores the information required to render the entity on the screen.
Definition: Components.hpp:13
std::shared_ptr< sf::Texture > texture
The texture that the sprite uses.
Definition: Components.hpp:33
RenderComponent()
Construct a new RenderComponent.
sf::Sprite sprite
The sprite that will be rendered to represent the entity.
Definition: Components.hpp:38
static const std::string RENDER_COMP_ID
The ID of RenderComponent.
Definition: Components.hpp:18
A component for storing the 2D velocity of an entity.
Definition: Components.hpp:71
VelocityComponent()
Construct a new Velocity Component object.
static const std::string VEL_COMP_ID
The ID of a VelocityComponent.
Definition: Components.hpp:76
sf::Vector2f velocity
The entity's velocity.
Definition: Components.hpp:88