Simple C++ Game
BallSystem.hpp
1 #pragma once
2 
3 #include <IteratingSystem.hpp>
4 #include <Dispatcher.hpp>
5 
6 #include <SFML/Graphics.hpp>
7 
16 {
17 public:
21  static const std::string PLAYER_SCORE_EVENT;
22 
26  static const std::string ENEMY_SCORE_EVENT;
27 
35  BallSystem(Dispatcher &dispatcher, Entity &player, Entity &enemy);
36 
37 protected:
46  void process(std::shared_ptr<Entity> &entity, sf::Time deltaTime);
47 
48 private:
49  Entity &_player;
50  Entity &_enemy;
51 
52  sf::FloatRect _top;
53  sf::FloatRect _bottom;
54  sf::FloatRect _left;
55  sf::FloatRect _right;
56 
57  Dispatcher &_dispatcher;
58 
59  void slightlyRandomize(sf::Vector2f &velocity) const;
60 };
A system that handles the ball physics.
Definition: BallSystem.hpp:16
void process(std::shared_ptr< Entity > &entity, sf::Time deltaTime)
Processes a ball.
static const std::string ENEMY_SCORE_EVENT
The Event ID indicating the enemy AI has scored.
Definition: BallSystem.hpp:26
static const std::string PLAYER_SCORE_EVENT
The Event ID indicating the player has scored.
Definition: BallSystem.hpp:21
BallSystem(Dispatcher &dispatcher, Entity &player, Entity &enemy)
Constructs a new Ball System.
A class for managing events.
Definition: Dispatcher.hpp:18
An entity in the game's component entity system.
Definition: Entity.hpp:14
An implementation of EntitySystem that iterates through all Entity objects in EntitySystem::getEntiti...
Definition: IteratingSystem.hpp:10