Game Class
The Game class manages a game. This class loads the level logic and the logic of all of the user entities.
The Game class implementation can be found in the data/framework/game/game.h file.
Game Class
Members
int getActiveLevelIndex()
Returns an index of the active level.Return value
Active level index.void setFields(Entity entity)
Invokes all of the setter fields methods of the entity with the corresponding entity values.Arguments
- Entity entity - Entity.
GameData getGameData()
Returns game data.Return value
Game data.float getGameIFps()
Returns the engine ifps. It is the fastest way to get the ifps.Return value
Engine ifps.void setGameParameter(string name, variable value)
Sets the game custom parameter.Arguments
- string name - Unique parameter name.
- variable value - Parameter value. The value can be the following types: int, float, double, vec3, vec4, string.
variable getGameParameter(string name)
Returns the custom parameter value.Arguments
- string name - Parameter name.
Return value
Custom parameter value if it is found; otherwise 0.variable getGameParameter(string name, int default_value)
Returns a parameter value.Arguments
- string name - Parameter name.
- int default_value - Default value.
Return value
Custom parameter value if it is found; otherwise a default value.int isGameParameter(string name)
Returns a value indicating if the game parameter exists.Arguments
- string name - Parameter name.
Return value
1 if the parameter exists; otherwise 0.string getLogicNamespaceName()
Returns the name of the namespace, which contains the custom logic.Return value
Namespace name.float getPhysicsIFps()
Returns the physics ifps. It is the fastest way to get the physics ifps.Return value
Physics ifps.Entity createEntity(string type)
Creates an Entity class instance.Arguments
- string type - Entity type.
Return value
Entity class instance.void flush()
Updates game physics.Game()
Constructor. Creates a new Game class instance.void init(GameData data, int level_index)
Creates a game and initializes the necessary resources on the game launch.Arguments
- GameData data - Game data.
- int level_index - Loaded level index.
void loadLevel(variable index)
Loads a level.Arguments
- variable index - Level number if index is an integer; level name if index is a string.
void render()
Updates a game after the update() function is invoked.void shutdown()
Releases game resources.void update()
Updates a game.Last update: 2017-07-03
Help improve this article
Was this article helpful?
(or select a word/phrase and press Ctrl+Enter)