Utils

Utils

Description

SwinGame's Utils contain a number of helper routines that can be useful in general game development.

Calculate Framerate

Returns the calculated framerate averages, highest, and lowest values along with the suggested rendering color.

  • Calculate Framerate (out average, out highest, out lowest, out textColor) [show]

    Returns the calculated framerate averages, highest, and lowest values along with the suggested rendering color.

    Parameters:
    average : String
    highest : String
    lowest : String
    textColor : Color
    Signatures by Language:
    C/C++: void calculate_framerate(char *average, char *highest, char *lowest, color *textColor);
    C++: void calculate_framerate(char *average, char *highest, char *lowest, color &textColor);
    Pascal: procedure CalculateFramerate(out average: String; out highest: String; out lowest: String; out textColor: Color);

Delay

Puts the process to sleep for a specified number of milliseconds. This can be used to add delays into your game.

  • Delay (time) [show]

    Puts the process to sleep for a specified number of milliseconds. This can be used to add delays into your game.

    Parameters:
    time : Longword
    The number of milliseconds to sleep

    Side Effects - Delay before returning

    Signatures by Language:
    C/C++: void delay(uint32_t time);
    Pascal: procedure Delay(time: Longword);

Exception Message

This function can be used to retrieve a message containing the details of the last error that occurred in SwinGame.

  • Exception Message () : String [show]

    This function can be used to retrieve a message containing the details of the last error that occurred in SwinGame.

    Returns:
    String :
    Signatures by Language:
    C/C++: void exception_message(char *result);
    Pascal: function ExceptionMessage(): String;

Exception Occured

This function tells you if an error occurred with the last operation in SwinGame.

  • Exception Occured () : Boolean [show]

    This function tells you if an error occurred with the last operation in SwinGame.

    Returns:
    Boolean :
    Signatures by Language:
    C/C++: bool exception_occured();
    Pascal: function ExceptionOccured(): Boolean;

Get Framerate

Returns the average framerate for the last 10 frames as an integer.

  • Get Framerate () : Longint [show]

    Returns the average framerate for the last 10 frames as an integer.

    Returns:
    Longint : The current average framerate
    Signatures by Language:
    C/C++: int32_t get_framerate();
    Pascal: function GetFramerate(): Longint;

Get Ticks

Gets the number of milliseconds that have passed. This can be used to determine timing operations, such as updating the game elements.

  • Get Ticks () : Longword [show]

    Gets the number of milliseconds that have passed. This can be used to determine timing operations, such as updating the game elements.

    Returns:
    Longword : The number of milliseconds passed
    Signatures by Language:
    C/C++: uint32_t get_ticks();
    Pascal: function GetTicks(): Longword;

Rnd

Generates a random number between 0 and 1.

  • Rnd () : Single [show]

    Generates a random number between 0 and 1.

    Returns:
    Single :
    Signatures by Language:
    C/C++: float rnd();
    Pascal: function Rnd(): Single;
  • Rnd (ubound) : Longint [show]

    Generates a random integer up to (but not including) ubound. Effectively, the ubound value specifies the number of random values to create.

    Parameters:
    ubound : Longint
    Returns:
    Longint :
    Signatures by Language:
    C/C++: int32_t rnd_upto(int32_t ubound);
    C++: int32_t rnd(int32_t ubound);
    Pascal: function Rnd(ubound: Longint): Longint;

Swin Game Version

Retrieves a string representing the version of SwinGame that is executing. This can be used to check that the version supports the features required for your game.

  • Swin Game Version () : String [show]

    Retrieves a string representing the version of SwinGame that is executing. This can be used to check that the version supports the features required for your game.

    Returns:
    String :
    Signatures by Language:
    C/C++: void swin_game_version(char *result);
    Pascal: function SwinGameVersion(): String;