Why is this fuction included in initialiser list?

Hello again,

I've just started the SFML Game Development book. The first chapter deals with setting up a game loop and rendering basic shapes to a window. All good so far, but I don't quite understand a small section of the class constructor.

The class in part is:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
class Game
{
public:
	Game();
	void run();

private:
	void processEvents();
	void update(sf::Time deltaTime);
	void render();

private:

	static const float PlayerSpeed;
	sf::RenderWindow mWindow;
	sf::CircleShape mPlayer;

	void handlePlayerInput(sf::Keyboard::Key key, bool isPressed);

	bool mIsMovingUp;
	bool mIsMovingDown;
	bool mIsMovingLeft;
	bool mIsMovingRight;
};

Game::Game()	// Default constructor
	: mWindow (sf::VideoMode(640, 480), "SFML App")	
	, mPlayer()
	, mIsMovingUp(false)		
	, mIsMovingDown(false)
	, mIsMovingLeft(false)
	, mIsMovingRight(false)
{
	mPlayer.setRadius(40.F);mPlayer
	mPlayer.setPosition(100.f, 100.f);
	mPlayer.setFillColor(sf::Color::Cyan);
}


Simply, I don't understand why mPlayer() is included in the initialiser list?

When the default constructor is called, the functions for setting radius/position/colour are triggered regardless of mPlayer being included, at least as far as I can see. Removing it has no perceivable effect on the program (just moving a shape around a window with WASD).

I can see why mWindow is called, to initialise the RenderWindow with resulution and title, but I can't see what purpose mPlayer() serves. Could this be explained to me please?
Topic archived. No new replies allowed.