My Project
|
The FoodGameEntity struct is designed to represent food entities in the game, handling their visualization and behavior. More...
#include <FoodGameEntity.h>
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. | |
![]() | |
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 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.
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.
|
inlineoverridevirtual |
Renders the entity and its components.
renderer | The SDL renderer to draw to. |
If the entity is marked as renderable, iterates over all components and renders each one.
Reimplemented from GameEntity.
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.