This page has been translated automatically.
编程
Fundamentals
Setting Up Development Environment
UnigineScript
High-Level Systems
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
应用程序接口
Containers
Common Functionality
Controls-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
Rendering-Related Classes
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

Unigine::Game Class

Header:#include <UnigineGame.h>

This class contains functions to control the game logic of the application. It provides functionality for:

  • Assigning a player to the editor_game viewport.
  • Pausing, speeding up and slowing down the game logic.

Game Class

Members


Game * get()

Returns a pointer to the Game instance.

Return value

Game instance.

void setData(const char * data)

Sets user data associated with the world. In the *.world file, the data is set in the data tag.

Arguments

  • const char * data - User data. Data can contain an XML formatted string.

const char * getData()

Returns user string data associated with the world. This string is written directly into the data tag of the *.world file.

Return value

User string data.

void setEnabled(int enabled)

Pauses or resumes the current game.

Arguments

  • int enabled - 1 to resume the game, 0 to pause it.

int isEnabled()

Returns a value indicating if the game is paused or not.

Return value

Returns 1 if the game is not paused; otherwise, 0.

void setFrame(int frame)

Sets the game frame number.

Arguments

  • int frame - Frame number.

int getFrame()

Returns the current game frame number.

Return value

Frame number.

void setFTime(float ftime)

Sets the maximum rendering frame duration value. If the real rendering FPS is higher than the fixed frame FPS, the engine will wait until the fixed frame time is over. To remove fixed frame duration, use -1.

Arguments

  • float ftime - Frame time in seconds. -1 removes the FPS limitation.

float getFTime()

Returns time spent between a previous update and a current one. This function takes time scaling into account.

Return value

Frame time in seconds.

void setIFps(float ifps)

Sets the inverse FPS value. This function sets a fixed FPS that does not depend on the real FPS the hardware is capable of. To remove the FPS limitation, use -1.

Arguments

  • float ifps - Inverse FPS value (1/FPS) in seconds.-1 removes the FPS limitation.

float getIFps()

Returns the scaled (see the setScale() function) inverse FPS value.

Return value

Scaled inverse FPS value (1/FPS) in seconds. If the game is paused, 0 is returned.

Ptr<Obstacle> getIntersection(const Math::Vec3 & p0, const Math::Vec3 & p1, float radius, int mask, const Vector< Ptr<Node> > & exclude, Math::Vec3 * intersection)

Performs intersection to find if a pathfinding Obstacle is located within the cylinder between two points. The specified obstacles will be ignored.
Notice
World space coordinates are used for this function.

Arguments

  • const Math::Vec3 & p0 - Start point.
  • const Math::Vec3 & p1 - End point.
  • float radius - Radius of the intersection cylinder.
  • int mask - Obstacle intersection mask. The obstacle is ignored if its mask does not match.
  • const Vector< Ptr<Node> > & exclude - Array with excluded obstacles. These obstacle nodes are ignored when performing intersection.
  • Math::Vec3 * intersection - Intersection point.

Return value

Intersected obstacle.

Ptr<Obstacle> getIntersection(const Math::Vec3 & p0, const Math::Vec3 & p1, float radius, int mask, const Ptr<GameIntersection> & intersection)

Performs intersection to find if a pathfinding obstacle is located within the cylinder between two points.

Notice
World space coordinates are used for this function.

Arguments

  • const Math::Vec3 & p0 - Start point.
  • const Math::Vec3 & p1 - End point.
  • float radius - Radius of the intersection cylinder.
  • int mask - Obstacle intersection mask. The obstacle is ignored if its mask does not match.
  • const Ptr<GameIntersection> & intersection - GameIntersection class instance to put the result into.

Return value

Intersected obstacle.

float getNoise1(float pos, float size, int frequency)

Returns a noise value calculated using a Perlin noise function.

Arguments

  • float pos - Float position.
  • float size - Size of the noise.
  • int frequency - Noise frequency.

Return value

Noise value.

float getNoise2(const Math::vec2 & pos, const Math::vec2 & size, int frequency)

Returns a 2D noise value calculated using a Perlin noise function.

Arguments

  • const Math::vec2 & pos - vec2 point position.
  • const Math::vec2 & size - vec2 size of the noise.
  • int frequency - Noise frequency.

Return value

2D noise value.

float getNoise3(const Math::vec3 & pos, const Math::vec3 & size, int frequency)

Returns a 3D noise value calculated using a Perlin noise function.

Arguments

  • const Math::vec3 & pos - vec3 point position.
  • const Math::vec3 & size - vec3 size of the noise.
  • int frequency - Noise frequency.

Return value

3D noise value.

void setPlayer(const Ptr<Player> & player)

Sets the current game player.

Arguments

  • const Ptr<Player> & player - Game player.

Ptr<Player> getPlayer()

Returns the current player.

Return value

Current player.

unsigned int getRandom()

Returns a pseudo-random unsigned integer number.

Return value

Random unsigned integer number.

double getRandomDouble(double from, double to)

Returns a pseudo-random double number within a given range.

Arguments

  • double from - The initial point of the range.
  • double to

Return value

Random double integer number.

float getRandomFloat(float from, float to)

Returns a pseudo-random float number within a given range.

Arguments

  • float from - The initial point of the range.
  • float to

Return value

Random float integer number.

int getRandomInt(int from, int to)

Returns a pseudo-random integer number within a given range.

Arguments

  • int from - The initial point of the range.
  • int to - The end point of the range.

Return value

Random integer number.

void setScale(float scale)

Sets a value that is used to scale frame duration. It scales up or down the speed of rendering, physics and game logic. This function can be used to create effects of slow/accelerated motion.For example, if the scale equals 2, the rate of simulation of all effects (such as particles) speeds up to two times faster. This function scales both setIFps() and setFTime() functions. The default is 1.

Arguments

  • float scale - Scaling factor. The provided values is clamped within range [0;32].

float getScale()

Returns a value used to scale a frame duration.

Return value

Value to scale frame duration.

void setSeed(int seed)

Sets the seed for pseudo-random number generator.

Arguments

  • int seed - Number used to initialize a pseudo-random sequence of numbers. Non-negative value should be provided, as unsigned integer is used for it.

int getSeed()

Returns the seed for pseudo-random number generator.

Return value

Number used to initialize a pseudo-random sequence of numbers.

void setTime(float time)

Sets a specified time value for the game. The time is counted off starting from the world loading and does not take game pauses into account.

Arguments

  • float time - Time value in seconds.

float getTime()

Returns the current time spent in the game. It is counted off starting from the world loading and does not take game pauses into account.

Return value

Time value in seconds.
Last update: 2017-07-03
Build: ()