The Table Engine
|
Handles player interactions, movements, and animation states based on game input. More...
#include <player_input_script.h>
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... | |
![]() | |
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... | |
GameObject * | getOwner () |
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 | |
![]() | |
std::string | m_name |
Name of the script, useful for identification or debugging. More... | |
GameObject * | m_owner |
Pointer to the GameObject that owns this script. More... | |
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.
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.
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.
int PlayerInputScript::getKeysCollected | ( | ) |
Retrieves the number of keys collected by the player.
Definition at line 23 of file player_input_script.cpp.
|
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.
|
private |
Current animation state of the player.
Definition at line 40 of file player_input_script.h.
|
private |
Number of keys the player has collected.
Definition at line 39 of file player_input_script.h.
|
private |
Timestamp of the last fire to regulate shooting frequency.
Definition at line 36 of file player_input_script.h.
|
private |
Speed at which the player moves.
Definition at line 38 of file player_input_script.h.