C++ Project 2016-2017: Arkanoid
ball.h
Go to the documentation of this file.
1 
3 #ifndef BALL_H
4 #define BALL_H
5 
6 #include "../entity.h"
7 #include "../player/player.h"
8 #include "../../math/vector2D.h"
9 #include "../../math/random.h"
10 
11 #include <iostream>
12 #include <memory>
13 #include <vector>
14 
15 using namespace std;
16 
17 
18 namespace arkanoid {
19 
21  class Ball : public Entity {
22  protected:
23  Vector2D velocity;
24  Vector2D origin;
25 
26  double speed;
27  bool notMoving;
28  int invisDuration;
29  bool spedUp;
30 
31  Random* random;
32 
33  public:
34 
40  Ball();
41 
52  Ball(double x, double y, double newSpeed = 8.0, pair<double, double> size = make_pair(1.0, 1.0));
53 
57  ~Ball();
58 
62  void update();
63 
67  void draw() const ;
68 
74  void speedUp(double factor);
75 
81  void setInvisible(int period);
82 
90  template<typename T>
91  vector<int> bounceIfPossible(vector<unique_ptr<T>> const &entities);
92 
98  void bounceIfPossible(unique_ptr<Player> const &player);
99 
104  virtual void reset();
105 
106  };
107 
108 }
109 
110 #endif /* BALL_H */
Representation of a vector.
Definition: vector2D.h:14
Singleton: generates "random" numbers.
Definition: random.h:14
All the game logic of the Arkanoid game.
Definition: ball.cpp:15
An Entity represents an "object" (like Player, Ball, Block, ...) in the game World.
Definition: entity.h:15
The Ball in the Arkanoid game.
Definition: ball.h:21