dEngine
Simple 2D C++ game engine
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
dengine::GameLevel Class Referenceabstract

A level of the game. More...

#include <GameLevel.h>

Public Member Functions

 GameLevel ()
 Creates a new gamelevel. More...
 
virtual ~GameLevel ()
 Cleans up and removes any memory allocated by GameLevel. More...
 
virtual void Load ()=0
 Used for loading assets into memory. More...
 
virtual void UnLoad ()=0
 Used for removing assets from memory. More...
 
virtual void Update ()=0
 Used for performing logic updates. More...
 
virtual void Render ()=0
 Used for rendering graphics, text and more. More...
 
virtual void Start ()=0
 Called at instantiation. More...
 
virtual void Pause ()=0
 Pauses the game. More...
 
virtual void Resume ()=0
 Resumes the game. More...
 
virtual std::weak_ptr< GameObjectAddObject (GameObject *go)
 Adds an object to the level. More...
 
virtual std::weak_ptr< GameObjectGetObject (std::string gameObjectName)
 Retrieves a pointer to the object from the level. More...
 
virtual std::weak_ptr< GameObjectGetObjectByComponent (std::string componentName)
 Retrieves an object from the level based on if it has a component or not. More...
 

Protected Member Functions

void StartObjects ()
 Calls the start method on any registered objects. More...
 
virtual void UpdateObjects ()
 Calls the Update method on any registered objects. More...
 
virtual void RenderObjects ()
 Calls the Render method on any registered objects. More...
 

Protected Attributes

bool started
 Is true if Start has already ran. More...
 
std::vector< std::shared_ptr< GameObject > > objects
 
std::vector< std::shared_ptr< GameObject > > newObjects
 

Detailed Description

A level of the game.

This is the base level for individual game development. A game level could be a title screen, a traditional level for the game or more. This is where all the objects will live and is what will act as an interface between the GameObjects and the Game

See also
Game
GameObject

Constructor & Destructor Documentation

◆ GameLevel()

GameLevel::GameLevel ( )

Creates a new gamelevel.

◆ ~GameLevel()

GameLevel::~GameLevel ( )
virtual

Cleans up and removes any memory allocated by GameLevel.

Member Function Documentation

◆ AddObject()

std::weak_ptr< GameObject > GameLevel::AddObject ( GameObject go)
virtual

Adds an object to the level.

◆ GetObject()

std::weak_ptr< GameObject > GameLevel::GetObject ( std::string  gameObjectName)
virtual

Retrieves a pointer to the object from the level.

◆ GetObjectByComponent()

std::weak_ptr< GameObject > GameLevel::GetObjectByComponent ( std::string  componentName)
virtual

Retrieves an object from the level based on if it has a component or not.

◆ Load()

virtual void dengine::GameLevel::Load ( )
pure virtual

Used for loading assets into memory.

Referenced by dengine::Game::Push().

◆ Pause()

virtual void dengine::GameLevel::Pause ( )
pure virtual

Pauses the game.

◆ Render()

virtual void dengine::GameLevel::Render ( )
pure virtual

Used for rendering graphics, text and more.

◆ RenderObjects()

void GameLevel::RenderObjects ( )
protectedvirtual

Calls the Render method on any registered objects.

◆ Resume()

virtual void dengine::GameLevel::Resume ( )
pure virtual

Resumes the game.

◆ Start()

virtual void dengine::GameLevel::Start ( )
pure virtual

Called at instantiation.

Referenced by dengine::Game::loop().

◆ StartObjects()

void GameLevel::StartObjects ( )
protected

Calls the start method on any registered objects.

◆ UnLoad()

virtual void dengine::GameLevel::UnLoad ( )
pure virtual

Used for removing assets from memory.

◆ Update()

virtual void dengine::GameLevel::Update ( )
pure virtual

Used for performing logic updates.

◆ UpdateObjects()

void GameLevel::UpdateObjects ( )
protectedvirtual

Calls the Update method on any registered objects.

Member Data Documentation

◆ newObjects

std::vector<std::shared_ptr<GameObject> > dengine::GameLevel::newObjects
protected

◆ objects

std::vector<std::shared_ptr<GameObject> > dengine::GameLevel::objects
protected

◆ started

bool dengine::GameLevel::started
protected

Is true if Start has already ran.

See also
Start

Referenced by AddObject().