HeadBall  1.0
A game
Public Member Functions | Private Attributes | List of all members
HeadBall::Player Class Reference

Class for shape and movement of player. More...

#include <Player.hpp>

Collaboration diagram for HeadBall::Player:
Collaboration graph

Public Member Functions

 Player (GameDataRef data, WorldRef world)
 Construct a new Player object. More...
 
void init (std::string texture, std::string texturePath, sf::Vector2f position)
 Initiate the Player object. More...
 
sf::Sprite sprite ()
 Return the sprite of the Player object. More...
 
void processPosition ()
 Process the position of Player object. More...
 
void moveLeft ()
 Move the player left. More...
 
void moveRight ()
 Move the player right. More...
 
void jump ()
 Make the player jump. More...
 
void setTexture (std::string texture)
 Set the Texture of the sprite. More...
 

Private Attributes

GameDataRef _data
 The Shared Pointer of the game data. More...
 
WorldRef _world
 The Shared Pointer of Box2D World. More...
 
sf::Sprite _sprite
 The SFML sprite of the player. More...
 
b2BodyDef _bodyDef
 The definition of Box2D body. More...
 
b2Body * _body
 The Box2D body of player. More...
 
b2PolygonShape _rectShape
 The polygon shape for fixture definition. More...
 
b2FixtureDef _fixture
 The fixture of player for defining its properties. More...
 

Detailed Description

Class for shape and movement of player.

Constructor & Destructor Documentation

◆ Player()

HeadBall::Player::Player ( GameDataRef  data,
WorldRef  world 
)

Construct a new Player object.

Parameters
dataShared pointer of game data
worldShared pointer of Box2D world

Member Function Documentation

◆ init()

void HeadBall::Player::init ( std::string  texture,
std::string  texturePath,
sf::Vector2f  position 
)

Initiate the Player object.

Parameters
textureTexture of the player as defined in the map
texturePathPath to the texture
positionPosition of the player

◆ jump()

void HeadBall::Player::jump ( )

Make the player jump.

◆ moveLeft()

void HeadBall::Player::moveLeft ( )

Move the player left.

◆ moveRight()

void HeadBall::Player::moveRight ( )

Move the player right.

◆ processPosition()

void HeadBall::Player::processPosition ( )

Process the position of Player object.

This function processes the position of the sprite as per the position of body in Box2D

◆ setTexture()

void HeadBall::Player::setTexture ( std::string  texture)

Set the Texture of the sprite.

Parameters
textureTexture as defined in the map

◆ sprite()

sf::Sprite HeadBall::Player::sprite ( )

Return the sprite of the Player object.

Returns
sf::Sprite Sprite of the player object

Member Data Documentation

◆ _body

b2Body* HeadBall::Player::_body
private

The Box2D body of player.

◆ _bodyDef

b2BodyDef HeadBall::Player::_bodyDef
private

The definition of Box2D body.

◆ _data

GameDataRef HeadBall::Player::_data
private

The Shared Pointer of the game data.

◆ _fixture

b2FixtureDef HeadBall::Player::_fixture
private

The fixture of player for defining its properties.

◆ _rectShape

b2PolygonShape HeadBall::Player::_rectShape
private

The polygon shape for fixture definition.

◆ _sprite

sf::Sprite HeadBall::Player::_sprite
private

The SFML sprite of the player.

◆ _world

WorldRef HeadBall::Player::_world
private

The Shared Pointer of Box2D World.


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