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

The FoodGameEntity struct is designed to represent food entities in the game, handling their visualization and behavior. More...

#include <FoodGameEntity.h>

Inheritance diagram for FoodGameEntity:
GameEntity

Public Member Functions

 FoodGameEntity (SDL_Renderer *renderer)
 
virtual void Input (float deltaTime) override
 Handles input for the entity.
 
virtual void Update (float deltaTime) override
 Updates the entity and its components.
 
virtual void Render (SDL_Renderer *renderer) override
 Renders the entity and its components.
 
- 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 FoodGameEntity struct is designed to represent food entities in the game, handling their visualization and behavior.

Inherits from GameEntity and adds a SpriteComponent to render a food image. This entity is used to represent food items in the game.

Member Function Documentation

◆ Input()

virtual void FoodGameEntity::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.

◆ Render()

virtual void FoodGameEntity::Render ( SDL_Renderer * renderer)
inlineoverridevirtual

Renders the entity and its components.

Parameters
rendererThe SDL renderer to draw to.

If the entity is marked as renderable, iterates over all components and renders each one.

Reimplemented from GameEntity.

◆ Update()

virtual void FoodGameEntity::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: