Simple C++ Game
|
A system that handles the ball physics. More...
#include <BallSystem.hpp>
Public Member Functions | |
BallSystem (Dispatcher &dispatcher, Entity &player, Entity &enemy) | |
Constructs a new Ball System. More... | |
![]() | |
IteratingSystem () | |
Construct a new IteratingSystem with the default EntitySystem constructor. More... | |
IteratingSystem (const std::shared_ptr< EntityFamily > &family) | |
Construct a new IteratingSystem with the EntityFamily EntitySystem constructor. More... | |
void | update (const sf::Time deltaTime) |
Iterates through each element in the system to perform updates. More... | |
![]() | |
EntitySystem () | |
Construct a new default EntitySystem. More... | |
EntitySystem (const std::shared_ptr< EntityFamily > &family) | |
Construct a new EntitySystem that acts on a specified family. More... | |
virtual void | engineEntityAdded (const std::shared_ptr< Entity > &entity) |
Performs any operations required after an entity has been added to an EntityEngine the system is a part of. More... | |
Static Public Attributes | |
static const std::string | PLAYER_SCORE_EVENT |
The Event ID indicating the player has scored. | |
static const std::string | ENEMY_SCORE_EVENT |
The Event ID indicating the enemy AI has scored. | |
Protected Member Functions | |
void | process (std::shared_ptr< Entity > &entity, sf::Time deltaTime) |
Processes a ball. More... | |
![]() | |
virtual std::map< int, std::shared_ptr< Entity > > | getEntities () const |
Get the Entities in the system. More... | |
A system that handles the ball physics.
This system handles the unique aspects of ball physics, including bouncing off of walls and detecting successful scores. It acts on Entities with LocationComponent, VelocityComponent, and BallComponent.
BallSystem::BallSystem | ( | Dispatcher & | dispatcher, |
Entity & | player, | ||
Entity & | enemy | ||
) |
Constructs a new Ball System.
dispatcher | The dispatcher on which the system will post the PLAYER_SCORE_EVENT and ENEMY_SCORE_EVENT. |
player | A reference to the player. Its LocationComponent is used for collision detection with the paddle. |
enemy | A referece to the enemy AI. Its LocationComponent is used for collection detection with the paddle. |
|
protectedvirtual |
Processes a ball.
Processes a ball to see if it needs to bounce off a wall or has scored for either the player or the AI enemy.
entity | The current ball to process. |
deltaTime | The amount of time that has passed since the last call to process() for this ball. |
Implements IteratingSystem.