EzGL
Static Public Member Functions | Data Fields
EzGL::Object Class Referencefinal

Object factory and Main game executor. More...

#include <Object.hpp>

Static Public Member Functions

static int Main (std::string const &fileName)
 Initialize and run the game. More...
 
static ObjectCreate (std::string const &objectName)
 Object factory. More...
 
static ObjectCreate (nlohmann::json &config)
 Object factory. More...
 
static bool Destroy (Object const &object)
 Object destroyer. More...
 
static void UpdateAll ()
 Only graphics API binding components should call this. More...
 

Data Fields

nlohmann::json data
 Modifiable object data. More...
 
Object const * other
 Interactor object pointer. More...
 

Detailed Description

Object factory and Main game executor.

This class is non-inheritable (final). Use components to extend the functionality of an object instead.

Member Function Documentation

◆ Create() [1/2]

Object & EzGL::Object::Create ( std::string const &  objectName)
static

Object factory.

Created objects are automatically added to the universe. The caller gets a reference to this new object but is not responsible for its memory management.

Parameters
objectNameName of the object to be created. This object name should appear in the bottom-most level of the provided main json file.
Returns
Reference to the newly created object.

◆ Create() [2/2]

Object & EzGL::Object::Create ( nlohmann::json &  config)
static

Object factory.

Created objects are automatically added to the universe. The caller gets a reference to this new object but is not responsible for its memory management.

Parameters
configStarting json data for the new object.
Returns
Reference to the newly created object.

◆ Destroy()

bool EzGL::Object::Destroy ( Object const &  object)
static

Object destroyer.

Removes the referenced object from the universe.

Parameters
objectReference to object you want to delete.
Returns
Whether the object was found and deleted or not.

◆ Main()

int EzGL::Object::Main ( std::string const &  fileName)
static

Initialize and run the game.

Parameters
fileNameFile name of the main json file relative to the executable, including the file extension. A c-string accepting version of this function exists too, but does not receive its own documentation subsection.
Returns
EXIT_SUCCESS or EXIT_FAILURE

◆ UpdateAll()

void EzGL::Object::UpdateAll ( )
static

Only graphics API binding components should call this.

Updates all the components of all objects in the universe. Should only be called once per frame.

Field Documentation

◆ data

nlohmann::json EzGL::Object::data

Modifiable object data.

Stores object parameters, runtime data, component information, etc. Consult the user guides for more on how the json files are parsed and loaded.

◆ other

Object const* EzGL::Object::other

Interactor object pointer.

Used in situations when two objects interact with one another. The Collision module, for example, sets each object's other pointers to the other when two objects collide. This pointer does not get reset at the end of each frame; it remains the same until it is overwritten.


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