Simple C++ Game
Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
BallSystem Class Reference

A system that handles the ball physics. More...

#include <BallSystem.hpp>

Inheritance diagram for BallSystem:
Inheritance graph
[legend]
Collaboration diagram for BallSystem:
Collaboration graph
[legend]

Public Member Functions

 BallSystem (Dispatcher &dispatcher, Entity &player, Entity &enemy)
 Constructs a new Ball System. More...
 
- Public Member Functions inherited from IteratingSystem
 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...
 
- Public Member Functions inherited from EntitySystem
 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...
 
- Protected Member Functions inherited from EntitySystem
virtual std::map< int, std::shared_ptr< Entity > > getEntities () const
 Get the Entities in the system. More...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ BallSystem()

BallSystem::BallSystem ( Dispatcher dispatcher,
Entity player,
Entity enemy 
)

Constructs a new Ball System.

Parameters
dispatcherThe dispatcher on which the system will post the PLAYER_SCORE_EVENT and ENEMY_SCORE_EVENT.
playerA reference to the player. Its LocationComponent is used for collision detection with the paddle.
enemyA referece to the enemy AI. Its LocationComponent is used for collection detection with the paddle.

Member Function Documentation

◆ process()

void BallSystem::process ( std::shared_ptr< Entity > &  entity,
sf::Time  deltaTime 
)
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.

Parameters
entityThe current ball to process.
deltaTimeThe amount of time that has passed since the last call to process() for this ball.

Implements IteratingSystem.


The documentation for this class was generated from the following file: