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

Derived class of State class with visibility mode public that includes main gameplay. More...

#include <GameState.hpp>

Inheritance diagram for HeadBall::GameState:
Inheritance graph
Collaboration diagram for HeadBall::GameState:
Collaboration graph

Public Member Functions

 GameState (GameDataRef data, ScoreTimeRef scoretime, bool is2ndHalf=false)
 Construct a new Game State object. More...
 
void init ()
 Initialize a new GameSate Object. More...
 
void handleInput ()
 Handles all the inputs of Game State. More...
 
void update ()
 Updates the rendering window according to the provided input. More...
 
void draw ()
 Draws all the SFML object in the rendering window. More...
 
void pause ()
 Pauses the game. More...
 
void resume ()
 Resumes the game. More...
 
void animate (std::string player)
 Animates the movement of the players. More...
 
void kick (std::string player)
 Kicks the ball when called by the player. More...
 
virtual void animate ()
 Vitrual function for performing animations. More...
 

Private Attributes

GameDataRef _data
 The shared pointer of GameData. More...
 
sf::Text _timeText
 
sf::Text _p1Score
 
sf::Text _p2Score
 The SFML text of Score and Time. More...
 
ScoreTimeRef _scoreTime
 The shared pointer of ScoreTimeData. More...
 
WorldRef _world = std::make_shared <b2World> (b2Vec2(WORLD_GRAVITY_X, WORLD_GRAVITY_Y))
 The shared pointer of Box2d world. More...
 
Ground _ground
 The Ground object. More...
 
UpHill _leftUpHill
 
UpHill _rightUpHill
 The Uphill objects. More...
 
Wall _wall
 The Wall objects. More...
 
GoalPost _leftPost
 
GoalPost _rightPost
 The GoalPost objects. More...
 
Player _p1
 
Player _p2
 The Player objects. More...
 
Ball _ball
 The Ball objects. More...
 
bool _isPaused
 The boolean variable to if the game is paused. More...
 
bool _isSecondHalf
 The boolean variable to check if the state is second half or not. More...
 
sf::Sprite _pauseBtn
 Sprite for pause button. More...
 
sf::Music _crowdCheerSfx
 Crowd cheer sound. More...
 
sf::Sound _btnClickSfx
 Sound effect for button click. More...
 
sf::Sound _longWhistleSfx
 Sound effect to play at the end of each half. More...
 
sf::Sound _shortWhistleSfx
 Sound effect to play at the start of every half and after every goal. More...
 
sf::Sound _playerKickSfx
 Sound effect to play when the ball is kicked. More...
 
int _p1MoveCounter
 The int variable to count Player1 movement. More...
 
int _p2MoveCounter
 The int variable to count Player2 movement. More...
 

Detailed Description

Derived class of State class with visibility mode public that includes main gameplay.

Constructor & Destructor Documentation

◆ GameState()

HeadBall::GameState::GameState ( GameDataRef  data,
ScoreTimeRef  scoretime,
bool  is2ndHalf = false 
)

Construct a new Game State object.

Parameters
dataThe shared pointer of GameData
scoretimeThe shared pointer of ScoreTimeData
is2ndHalfThe bool variable with default value false

Member Function Documentation

◆ animate() [1/2]

virtual void HeadBall::State::animate ( )
inlinevirtualinherited

Vitrual function for performing animations.

◆ animate() [2/2]

void HeadBall::GameState::animate ( std::string  player)

Animates the movement of the players.

Parameters
playerString object whose value is either "p1" or "p2"

◆ draw()

void HeadBall::GameState::draw ( )
virtual

Draws all the SFML object in the rendering window.

Implements HeadBall::State.

◆ handleInput()

void HeadBall::GameState::handleInput ( )
virtual

Handles all the inputs of Game State.

Implements HeadBall::State.

◆ init()

void HeadBall::GameState::init ( )
virtual

Initialize a new GameSate Object.

Implements HeadBall::State.

◆ kick()

void HeadBall::GameState::kick ( std::string  player)

Kicks the ball when called by the player.

Parameters
playerString object whose value is either "p1" or "p2"

◆ pause()

void HeadBall::GameState::pause ( )
virtual

Pauses the game.

Reimplemented from HeadBall::State.

◆ resume()

void HeadBall::GameState::resume ( )
virtual

Resumes the game.

Reimplemented from HeadBall::State.

◆ update()

void HeadBall::GameState::update ( )
virtual

Updates the rendering window according to the provided input.

Implements HeadBall::State.

Member Data Documentation

◆ _ball

Ball HeadBall::GameState::_ball
private

The Ball objects.

◆ _btnClickSfx

sf::Sound HeadBall::GameState::_btnClickSfx
private

Sound effect for button click.

◆ _crowdCheerSfx

sf::Music HeadBall::GameState::_crowdCheerSfx
private

Crowd cheer sound.

◆ _data

GameDataRef HeadBall::GameState::_data
private

The shared pointer of GameData.

◆ _ground

Ground HeadBall::GameState::_ground
private

The Ground object.

◆ _isPaused

bool HeadBall::GameState::_isPaused
private

The boolean variable to if the game is paused.

◆ _isSecondHalf

bool HeadBall::GameState::_isSecondHalf
private

The boolean variable to check if the state is second half or not.

◆ _leftPost

GoalPost HeadBall::GameState::_leftPost
private

◆ _leftUpHill

UpHill HeadBall::GameState::_leftUpHill
private

◆ _longWhistleSfx

sf::Sound HeadBall::GameState::_longWhistleSfx
private

Sound effect to play at the end of each half.

◆ _p1

Player HeadBall::GameState::_p1
private

◆ _p1MoveCounter

int HeadBall::GameState::_p1MoveCounter
private

The int variable to count Player1 movement.

◆ _p1Score

sf::Text HeadBall::GameState::_p1Score
private

◆ _p2

Player HeadBall::GameState::_p2
private

The Player objects.

◆ _p2MoveCounter

int HeadBall::GameState::_p2MoveCounter
private

The int variable to count Player2 movement.

◆ _p2Score

sf::Text HeadBall::GameState::_p2Score
private

The SFML text of Score and Time.

◆ _pauseBtn

sf::Sprite HeadBall::GameState::_pauseBtn
private

Sprite for pause button.

◆ _playerKickSfx

sf::Sound HeadBall::GameState::_playerKickSfx
private

Sound effect to play when the ball is kicked.

◆ _rightPost

GoalPost HeadBall::GameState::_rightPost
private

The GoalPost objects.

◆ _rightUpHill

UpHill HeadBall::GameState::_rightUpHill
private

The Uphill objects.

◆ _scoreTime

ScoreTimeRef HeadBall::GameState::_scoreTime
private

The shared pointer of ScoreTimeData.

◆ _shortWhistleSfx

sf::Sound HeadBall::GameState::_shortWhistleSfx
private

Sound effect to play at the start of every half and after every goal.

◆ _timeText

sf::Text HeadBall::GameState::_timeText
private

◆ _wall

Wall HeadBall::GameState::_wall
private

The Wall objects.

◆ _world

WorldRef HeadBall::GameState::_world = std::make_shared <b2World> (b2Vec2(WORLD_GRAVITY_X, WORLD_GRAVITY_Y))
private

The shared pointer of Box2d world.


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