The Table Engine
PlayerInputScript Class Reference

Handles player interactions, movements, and animation states based on game input. More...

#include <player_input_script.h>

+ Inheritance diagram for PlayerInputScript:
+ Collaboration diagram for PlayerInputScript:

Public Types

enum  AnimationState { IDLE = 0 , RUN = 1 , DEATH = 2 }
 Defines the possible animation states for the player. More...
 

Public Member Functions

 PlayerInputScript ()
 Constructor for PlayerInputScript. Initializes the script with default values for player speed and fire rate. More...
 
int getKeysCollected ()
 Retrieves the number of keys collected by the player. More...
 
void update () override
 Updates player state based on input. More...
 
- Public Member Functions inherited from Script
 Script ()
 Default constructor, initializes an empty script. More...
 
 Script (std::string name)
 Constructs a Script with a specified name. More...
 
virtual ~Script ()
 Virtual destructor to allow for cleanup in derived script classes. More...
 
std::string getName ()
 Retrieves the name of the script. More...
 
GameObjectgetOwner ()
 Retrieves the owner GameObject of this script. More...
 
void setOwner (GameObject *owner)
 Sets the owner of this script. More...
 
virtual void input ()
 Virtual method for handling input. Should be overridden by derived classes. More...
 
virtual void render ()
 Virtual method for rendering operations. Should be overridden by derived classes. More...
 

Private Attributes

int m_lastFireTimeInMs = 0
 Timestamp of the last fire to regulate shooting frequency. More...
 
float m_playerSpeed = 6
 Speed at which the player moves. More...
 
int m_keysCollected = 0
 Number of keys the player has collected. More...
 
AnimationState m_currentState = IDLE
 Current animation state of the player. More...
 

Additional Inherited Members

- Public Attributes inherited from Script
std::string m_name
 Name of the script, useful for identification or debugging. More...
 
GameObjectm_owner
 Pointer to the GameObject that owns this script. More...
 

Detailed Description

Handles player interactions, movements, and animation states based on game input.

PlayerInputScript controls how the player responds to keyboard inputs, managing actions such as moving at a defined speed and firing at a controlled rate. It also manages the player's animation states based on their current action.

Definition at line 23 of file player_input_script.h.

Member Enumeration Documentation

◆ AnimationState

Defines the possible animation states for the player.

Enumerator
IDLE 

Player is standing still.

RUN 

Player is moving.

DEATH 

Player has died.

Definition at line 29 of file player_input_script.h.

Constructor & Destructor Documentation

◆ PlayerInputScript()

PlayerInputScript::PlayerInputScript ( )

Constructor for PlayerInputScript. Initializes the script with default values for player speed and fire rate.

Definition at line 19 of file player_input_script.cpp.

Member Function Documentation

◆ getKeysCollected()

int PlayerInputScript::getKeysCollected ( )

Retrieves the number of keys collected by the player.

Returns
int The total number of keys collected.

Definition at line 23 of file player_input_script.cpp.

◆ update()

void PlayerInputScript::update ( )
overridevirtual

Updates player state based on input.

This method checks for player inputs and updates the player's position, actions, and animation states based on the input and current game state.

Reimplemented from Script.

Definition at line 27 of file player_input_script.cpp.

Member Data Documentation

◆ m_currentState

AnimationState PlayerInputScript::m_currentState = IDLE
private

Current animation state of the player.

Definition at line 40 of file player_input_script.h.

◆ m_keysCollected

int PlayerInputScript::m_keysCollected = 0
private

Number of keys the player has collected.

Definition at line 39 of file player_input_script.h.

◆ m_lastFireTimeInMs

int PlayerInputScript::m_lastFireTimeInMs = 0
private

Timestamp of the last fire to regulate shooting frequency.

Definition at line 36 of file player_input_script.h.

◆ m_playerSpeed

float PlayerInputScript::m_playerSpeed = 6
private

Speed at which the player moves.

Definition at line 38 of file player_input_script.h.


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