C++ Project 2016-2017: Arkanoid
Public Member Functions | List of all members
arkanoidSFML::BallSFML Class Reference

The SFML element that represents the arkanoid::Ball in the game. More...

#include <ball_sfml.h>

Inheritance diagram for arkanoidSFML::BallSFML:
arkanoid::Ball arkanoid::Entity

Public Member Functions

 BallSFML (double x, double y, sf::RenderWindow &window, double speed=8.0, const string &textureFile="data/sprites/ball/ball.png")
 
 ~BallSFML ()
 
void update ()
 
void draw () const
 
void reset ()
 
- Public Member Functions inherited from arkanoid::Ball
 Ball ()
 
 Ball (double x, double y, double newSpeed=8.0, pair< double, double > size=make_pair(1.0, 1.0))
 
 ~Ball ()
 
void update ()
 
void draw () const
 
void speedUp (double factor)
 
void setInvisible (int period)
 
template<typename T >
vector< int > bounceIfPossible (vector< unique_ptr< T >> const &entities)
 
void bounceIfPossible (unique_ptr< Player > const &player)
 
- Public Member Functions inherited from arkanoid::Entity
 Entity ()
 
 Entity (double x, double y, pair< double, double > newSize=make_pair(1.0, 1.0))
 
virtual ~Entity ()
 
Vector2D getPosition () const
 
void setPosition (double x, double y)
 
void setPosition (const Vector2D &vector)
 
void setSize (pair< double, double > newSize)
 
pair< double, double > getSize () const
 
bool collidesWith (const Entity &other) const
 

Additional Inherited Members

- Protected Attributes inherited from arkanoid::Ball
Vector2D velocity
 
Vector2D origin
 
double speed
 
bool notMoving
 
int invisDuration
 
bool spedUp
 
Randomrandom
 
- Protected Attributes inherited from arkanoid::Entity
Vector2D position
 The current position of the Entity (in the 9x7 grid).
 
pair< double, double > size
 The size (width and height respectively) of the Entity.
 

Detailed Description

The SFML element that represents the arkanoid::Ball in the game.

Definition at line 19 of file ball_sfml.h.

Constructor & Destructor Documentation

◆ BallSFML()

arkanoidSFML::BallSFML::BallSFML ( double  x,
double  y,
sf::RenderWindow &  window,
double  speed = 8.0,
const string &  textureFile = "data/sprites/ball/ball.png" 
)

Constructor.

Creates a BallSFML sprite in the World at a specific position in the game window. Also applies the texture to this BallSFML.

Parameters
xThe x (on screen) position of the arkanoid::Ball.
yThe y (on screen) position of the arkanoid::Ball.
windowThe SFML window.
speed(optional) The speed of the arkanoid::Ball.
textureFile(optional) The file that contains the texture of the BallSFML.

Definition at line 12 of file ball_sfml.cpp.

◆ ~BallSFML()

arkanoidSFML::BallSFML::~BallSFML ( )

Destructor.

Definition at line 31 of file ball_sfml.cpp.

Member Function Documentation

◆ draw()

void arkanoidSFML::BallSFML::draw ( ) const
virtual

Draws the BallSFML in the game window.

Implements arkanoid::Entity.

Definition at line 49 of file ball_sfml.cpp.

◆ reset()

void arkanoidSFML::BallSFML::reset ( )
virtual

Reset the position and direction of the arkanoid::Ball to the one of the starting position. (-> call this method when the Player missed the arkanoid::Ball).

Reimplemented from arkanoid::Ball.

Definition at line 55 of file ball_sfml.cpp.

◆ update()

void arkanoidSFML::BallSFML::update ( )
virtual

Updates the BallSFML position.

Implements arkanoid::Entity.

Definition at line 33 of file ball_sfml.cpp.


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