#include <Player.h>
Public Member Functions | |
Player (int x, int y, TileMap *newMap, Mix_Chunk *attackSound) | |
Constructor. More... | |
~Player () | |
Destructor. More... | |
void | Update (int x, int y, int *params) override |
Update the position and animation of player as well as camera's position. More... | |
void | Render (SDL_Renderer *ren) override |
Render the main character to the active viewport. More... | |
void | processInput (SDL_Event e) override |
Process user input. More... | |
void | setCurrTileMap (TileMap *newMap) |
Update current tilemap. More... | |
void | setCurrController (PlayerController *newController) |
Update current controller. More... | |
PlayerController * | getCurrController () |
Get current controller. More... | |
void | respondToInput (std::vector< bool > &keyPressed) |
std::pair< int, int > | GetPos () |
Get player's current position. More... | |
void | ResetPos () |
Reset Player's Position. More... | |
void | SetPos (int x, int y) |
Map generate use only. More... | |
void | SetHP (int amount) |
increment Player's hp by certain amount More... | |
int | GetHP () |
Get player's current HP. More... | |
void | AttackEnemies (std::vector< Position > &attackPivots) |
attempt to attck enemies. checks if any of the enemies is in attack range More... | |
void | SetEnemies (std::vector< GameObject * > enemies) |
set the reference to all enemies More... | |
void | CheckIfDie () |
Check if player's HP is equal to 0. More... | |
void | SetCurrMap (Map *map) |
Set the current map. More... | |
Public Member Functions inherited from GameObject | |
GameObject () | |
Constructor. More... | |
~GameObject () | |
Destructor. More... | |
void | removeComponent (std::string key) |
Remove a component in this gameobject. More... | |
void | addComponent (std::string key, Component *component) |
Add a component in this gameobject. More... | |
Component * | getComponent (std::string key) |
Get an reference of a component. More... | |
void | setActive (bool newState) |
activate / deactivate game object. inactive object won't be updated and rendered More... | |
bool | isActive () |
Get the state of the game. More... | |
int | getID () |
Get the unique id of the gameobject. More... | |
Additional Inherited Members | |
Static Public Attributes inherited from GameObject | |
static int | idCounter = 0 |
Protected Attributes inherited from GameObject | |
std::map< std::string, Component * > | m_components |
Store all the game components in a map. More... | |
bool | objState |
deactivated objects won't get updated/rendered More... | |
int | id |
the unique id More... | |
Player::Player | ( | int | x, |
int | y, | ||
TileMap * | newMap, | ||
Mix_Chunk * | attackSound | ||
) |
Constructor.
x | The x location of player's initial position. |
y | The x location of player's initial position. |
newMap | Reference to the player's tilemap. |
attackSound | Player attack sound effect. |
Player::~Player | ( | ) |
Destructor.
void Player::AttackEnemies | ( | std::vector< Position > & | attackPivots | ) |
attempt to attck enemies. checks if any of the enemies is in attack range
void Player::CheckIfDie | ( | ) |
Check if player's HP is equal to 0.
PlayerController * Player::getCurrController | ( | ) |
Get current controller.
int Player::GetHP | ( | ) |
Get player's current HP.
std::pair< int, int > Player::GetPos | ( | ) |
Get player's current position.
|
overridevirtual |
Process user input.
e | A SDL_Event that contains structures for the different event types. |
Reimplemented from GameObject.
|
overridevirtual |
Render the main character to the active viewport.
ren | Reference to SDL renderer. |
Reimplemented from GameObject.
void Player::ResetPos | ( | ) |
Reset Player's Position.
void Player::respondToInput | ( | std::vector< bool > & | keyPressed | ) |
void Player::setCurrController | ( | PlayerController * | newController | ) |
Update current controller.
newController | The new controller where the player is using. |
void Player::SetCurrMap | ( | Map * | map | ) |
Set the current map.
void Player::setCurrTileMap | ( | TileMap * | newMap | ) |
Update current tilemap.
newMap | The new map where the player is in. |
void Player::SetEnemies | ( | std::vector< GameObject * > | enemies | ) |
set the reference to all enemies
void Player::SetHP | ( | int | amount | ) |
increment Player's hp by certain amount
void Player::SetPos | ( | int | x, |
int | y | ||
) |
Map generate use only.
|
overridevirtual |
Update the position and animation of player as well as camera's position.
x | The x location of player's position. |
y | The x location of player's position. |
params | An int array stores additional data. |
Reimplemented from GameObject.