My Project
|
The PlayerGameEntity struct is specialized to represent the player character in the game. More...
#include <PlayerGameEntity.h>
Public Member Functions | |
PlayerGameEntity (SDL_Renderer *renderer) | |
void | Input (float deltaTime) override |
Handles input for the entity. | |
virtual void | Update (float deltaTime) override |
Updates the entity and its components. | |
void | Render (SDL_Renderer *renderer) override |
Renders the player entity using the associated renderer. | |
void | SetOnGround (float newY) |
Sets the player's ground state. | |
void | SetShouldFall (bool value) |
Controls whether the player should start falling. | |
bool | IsJumping () const |
Checks if the player is currently jumping. | |
float | GetVerticalSpeed () const |
Gets the player's current vertical speed. | |
![]() | |
GameEntity ()=default | |
Default constructor for GameEntity. | |
virtual | ~GameEntity () |
Virtual destructor for GameEntity. | |
void | SetRenderable (bool value) |
Sets the entity's renderable state. | |
bool | IsRenderable () const |
Checks if the entity is renderable. | |
template<typename T , typename... Args> | |
T * | AddComponent (Args &&...args) |
Adds a component to the entity. | |
template<typename T > | |
T * | GetComponent () |
Retrieves the first component of type T. | |
template<typename T > | |
const T * | GetComponent () const |
Retrieves the first component of type T, const version. | |
bool | Intersects (const GameEntity *e) const |
Checks if the entity intersects with another entity. | |
SDL_Rect | ConvertFRectToRect (const SDL_FRect &frect) const |
Converts an SDL_FRect to SDL_Rect by casting float values to ints. | |
Additional Inherited Members | |
![]() | |
std::vector< std::shared_ptr< Component > > | components |
bool | mRenderable {true} |
The PlayerGameEntity struct is specialized to represent the player character in the game.
Inherits from GameEntity and adds a SpriteComponent for the player's visual representation. This entity handles user input for movements like walking and jumping, and manages the physics of those actions.
|
inline |
Gets the player's current vertical speed.
This method returns the player's vertical speed.
Handles input for the entity.
deltaTime | The time since the last update. |
This method is meant to be overridden by derived classes to handle specific input actions.
Reimplemented from GameEntity.
|
inline |
Checks if the player is currently jumping.
|
inlineoverridevirtual |
Renders the player entity using the associated renderer.
renderer | The SDL renderer to draw the player sprite. |
Renders the player sprite if the entity is marked as renderable. Retrieves the SpriteComponent and invokes its render method.
Reimplemented from GameEntity.
Sets the player's ground state.
newY | The new Y-coordinate for players at the ground. |
This method is called to set the player's position to the ground level and adjust the jumping state accordingly.
Controls whether the player should start falling.
value | True if the player should fall, false if otherwise. |
Sets the player's on-ground state to false to initiate falling, typically used after jumping.
Updates the entity and its components.
deltaTime | The time since the last update. |
Iterates over all components and updates each one. Can be overridden by derived classes for additional update logic.
Reimplemented from GameEntity.