My Project
Loading...
Searching...
No Matches
Public Member Functions | List of all members
PlayerGameEntity Struct Reference

The PlayerGameEntity struct is specialized to represent the player character in the game. More...

#include <PlayerGameEntity.h>

Inheritance diagram for PlayerGameEntity:
GameEntity

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.
 
- Public Member Functions inherited from GameEntity
 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 >
TGetComponent ()
 Retrieves the first component of type T.
 
template<typename T >
const TGetComponent () 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

- Protected Attributes inherited from GameEntity
std::vector< std::shared_ptr< Component > > components
 
bool mRenderable {true}
 

Detailed Description

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.

Member Function Documentation

◆ GetVerticalSpeed()

float PlayerGameEntity::GetVerticalSpeed ( ) const
inline

Gets the player's current vertical speed.

Returns
The current vertical speed of the player.

This method returns the player's vertical speed.

◆ Input()

void PlayerGameEntity::Input ( float deltaTime)
inlineoverridevirtual

Handles input for the entity.

Parameters
deltaTimeThe time since the last update.

This method is meant to be overridden by derived classes to handle specific input actions.

Reimplemented from GameEntity.

◆ IsJumping()

bool PlayerGameEntity::IsJumping ( ) const
inline

Checks if the player is currently jumping.

Returns
True if the player is in the air, false if on the ground.

◆ Render()

void PlayerGameEntity::Render ( SDL_Renderer * renderer)
inlineoverridevirtual

Renders the player entity using the associated renderer.

Parameters
rendererThe 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.

◆ SetOnGround()

void PlayerGameEntity::SetOnGround ( float newY)
inline

Sets the player's ground state.

Parameters
newYThe 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.

◆ SetShouldFall()

void PlayerGameEntity::SetShouldFall ( bool value)
inline

Controls whether the player should start falling.

Parameters
valueTrue if the player should fall, false if otherwise.

Sets the player's on-ground state to false to initiate falling, typically used after jumping.

◆ Update()

virtual void PlayerGameEntity::Update ( float deltaTime)
inlineoverridevirtual

Updates the entity and its components.

Parameters
deltaTimeThe 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.


The documentation for this struct was generated from the following file: