Building Game Engines
PlayerController Class Reference

Control the input from users and update player's information. More...

#include <PlayerController.h>

Inheritance diagram for PlayerController:
Inheritance graph
Collaboration diagram for PlayerController:
Collaboration graph

Public Member Functions

 PlayerController ()=default
 Constructor. More...
 
 ~PlayerController ()=default
 Destructor. More...
 
float getSpeedX ()
 Return player's speed on horizontal direction. More...
 
float getSpeedY ()
 Return player's speed on vertical direction. More...
 
void applyGravity ()
 Apply gravity on player. More...
 
void playerIsOnGround (bool status)
 Check whether player on the ground. More...
 
PLAYER_STATE getState ()
 Return the player's state. More...
 
PLAYER_DIR getDir ()
 Return the player's current orientation. More...
 
void processInput (std::vector< bool > &keyPressed, int &x, int &y)
 
bool shouldReset ()
 
- Public Member Functions inherited from Component
 Component ()
 
 ~Component ()
 

Detailed Description

Control the input from users and update player's information.

Constructor & Destructor Documentation

◆ PlayerController()

PlayerController::PlayerController ( )
default

Constructor.

◆ ~PlayerController()

PlayerController::~PlayerController ( )
default

Destructor.

Member Function Documentation

◆ applyGravity()

void PlayerController::applyGravity ( )

Apply gravity on player.

◆ getDir()

PLAYER_DIR PlayerController::getDir ( )

Return the player's current orientation.

Returns
Return the player's current orientation. The direction contains left and right.

◆ getSpeedX()

float PlayerController::getSpeedX ( )

Return player's speed on horizontal direction.

Returns
The value of the speed.

◆ getSpeedY()

float PlayerController::getSpeedY ( )

Return player's speed on vertical direction.

Returns
The value of the speed.

◆ getState()

PLAYER_STATE PlayerController::getState ( )

Return the player's state.

Returns
Return the player's state. The state contains moving, still, jump, fall, hit and run.

◆ playerIsOnGround()

void PlayerController::playerIsOnGround ( bool  status)

Check whether player on the ground.

Parameters
statusThe current onground state.

◆ processInput()

void PlayerController::processInput ( std::vector< bool > &  keyPressed,
int &  x,
int &  y 
)

Process user input.

Parameters
keyPressedThe information of pressed keys.
x
y

◆ shouldReset()

bool PlayerController::shouldReset ( )