Game Engine 2D Platformer
Public Member Functions | Public Attributes | List of all members
GameEntity Class Reference

Represents an interactable entity in the game that includes Main Character, NPC, Tiles , and etc. More...

#include <GameEntity.hpp>

Collaboration diagram for GameEntity:
Collaboration graph
[legend]

Public Member Functions

 GameEntity (entityType eType)
 Constructor of GameEntity. More...
 
 ~GameEntity ()
 Destructor of GameEntity. More...
 
void StartUp (Vector2D position, Vector2D velocity, int width, int height)
 Initializes attributes for the GameEntity object. More...
 
void ShutDown ()
 Destrotys and free attributes of the GameEntity Class. More...
 
void Update ()
 Updates the position of the game entity. More...
 
void Render ()
 Renders the object on screen for the GameEntity Class. More...
 
SDL_Rect * GetRectangle ()
 Returns the Rectangle for GameEntity. More...
 
SDL_Event GetEvent ()
 Returns the Event for GameEntity. More...
 
int GetWidth ()
 Returns the Width of GameEntity. More...
 
int GetHeight ()
 Returns the Height of GameEntity. More...
 
void AddComponent (std::shared_ptr< Component > component)
 Adds different components to the GameEntity. More...
 
void SetEvent (SDL_Event &e)
 Sets the SDL_Event for GameEntity class. More...
 
void SetManager (EntityManager *entityManager)
 Sets EntityManager for GameEntity. More...
 
void Reset ()
 Resets the GameEntity. More...
 

Public Attributes

Vector2D position
 
Vector2D velocity
 
SDL_RendererFlip flip = SDL_FLIP_NONE
 
SDL_Rect rect
 
SDL_Rect src
 
SDL_Rect dest
 
SDL_Texture * m_texture
 
bool win = false
 
bool lose = false
 
int lives = 3
 
int score = 0
 
bool eatSound = false
 
bool deathSound = false
 
bool collectItemSound = false
 
bool jumpSound = false
 
bool cameraFlag = false
 
int xPosTile = 0
 
std::vector< int > collectablesAvailable
 
int arrayPos = 0
 
bool collectable = false
 
entityType eType
 
bool jumping = false
 
bool isGrounded = false
 
EntityManagerentityManager
 
Vector2D initialPosition
 
Vector2D initialVelocity
 

Detailed Description

Represents an interactable entity in the game that includes Main Character, NPC, Tiles , and etc.

Constructor & Destructor Documentation

◆ GameEntity()

GameEntity::GameEntity ( entityType  eType)

Constructor of GameEntity.

Parameters
eTypean Enum of entityType

◆ ~GameEntity()

GameEntity::~GameEntity ( )

Destructor of GameEntity.

Member Function Documentation

◆ AddComponent()

void GameEntity::AddComponent ( std::shared_ptr< Component component)

Adds different components to the GameEntity.

Adds component to the component vector in GameEntity.

Parameters
componentShared pointer to the Component object
std::shared_ptr<Component>component

◆ GetEvent()

SDL_Event GameEntity::GetEvent ( )

Returns the Event for GameEntity.

Returns the event stored in GameEntity

Returns
SDL_Event pointer to the actual Rectangle

◆ GetHeight()

int GameEntity::GetHeight ( )

Returns the Height of GameEntity.

Returns height of GameEntity.

Returns
Height of the GameEntity

◆ GetRectangle()

SDL_Rect * GameEntity::GetRectangle ( )

Returns the Rectangle for GameEntity.

Returns the rectangle stored in GameEntity.

Returns
SDL_Rect pointer to the actual Rectangle

◆ GetWidth()

int GameEntity::GetWidth ( )

Returns the Width of GameEntity.

Returns width of GameEntity.

Returns
Width of the GameEntity

◆ Render()

void GameEntity::Render ( )

Renders the object on screen for the GameEntity Class.

Calls all the render functions for each component in GameEntity

◆ Reset()

void GameEntity::Reset ( )

Resets the GameEntity.

◆ SetEvent()

void GameEntity::SetEvent ( SDL_Event &  e)

Sets the SDL_Event for GameEntity class.

Sets the GameEntity's event attribute to the param.

Parameters
eSDL_Event
SDL_Evente

◆ SetManager()

void GameEntity::SetManager ( EntityManager entityManager)

Sets EntityManager for GameEntity.

Parameters
entityA pointer to EntityManager object

◆ ShutDown()

void GameEntity::ShutDown ( )

Destrotys and free attributes of the GameEntity Class.

◆ StartUp()

void GameEntity::StartUp ( Vector2D  position,
Vector2D  velocity,
int  width,
int  height 
)

Initializes attributes for the GameEntity object.

Updates the position of the game entity.

Parameters
positionA Vector2D object that takes in x&y coordinates for the GameEntity
velocityA Vector2D object that takes in x&y velocity for the GameEntity
widthThe width of the GameEntity
heightThe height of the GameEntity
GameEntity&entity

◆ Update()

void GameEntity::Update ( )

Updates the position of the game entity.

Calls all the update functions for each component in GameEntity

Member Data Documentation

◆ arrayPos

int GameEntity::arrayPos = 0

◆ cameraFlag

bool GameEntity::cameraFlag = false

◆ collectable

bool GameEntity::collectable = false

◆ collectablesAvailable

std::vector<int> GameEntity::collectablesAvailable

◆ collectItemSound

bool GameEntity::collectItemSound = false

◆ deathSound

bool GameEntity::deathSound = false

◆ dest

SDL_Rect GameEntity::dest

◆ eatSound

bool GameEntity::eatSound = false

◆ entityManager

EntityManager* GameEntity::entityManager

◆ eType

entityType GameEntity::eType

◆ flip

SDL_RendererFlip GameEntity::flip = SDL_FLIP_NONE

◆ initialPosition

Vector2D GameEntity::initialPosition

◆ initialVelocity

Vector2D GameEntity::initialVelocity

◆ isGrounded

bool GameEntity::isGrounded = false

◆ jumping

bool GameEntity::jumping = false

◆ jumpSound

bool GameEntity::jumpSound = false

◆ lives

int GameEntity::lives = 3

◆ lose

bool GameEntity::lose = false

◆ m_texture

SDL_Texture* GameEntity::m_texture

◆ position

Vector2D GameEntity::position

◆ rect

SDL_Rect GameEntity::rect

◆ score

int GameEntity::score = 0

◆ src

SDL_Rect GameEntity::src

◆ velocity

Vector2D GameEntity::velocity

◆ win

bool GameEntity::win = false

◆ xPosTile

int GameEntity::xPosTile = 0

The documentation for this class was generated from the following files: