Libraries.Game.WebApplication Documentation

Inherits from: Libraries.Language.Object, Libraries.Game.Application

Actions Documentation

CheckForErrors()

This action queries OpenGL to see if any errors have ocurred in the graphics pipeline, and is used for debugging only.

Compare(Libraries.Language.Object object)

This action compares two object hash codes and returns an integer. The result is larger if this hash code is larger than the object passed as a parameter, smaller, or equal. In this case, -1 means smaller, 0 means equal, and 1 means larger. This action was changed in Quorum 7 to return an integer, instead of a CompareResult object, because the previous implementation was causing efficiency issues.

Parameters

Return

integer: The Compare result, Smaller, Equal, or Larger.

Example

Object o
Object t
integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)

Equals(Libraries.Language.Object object)

This action determines if two objects are equal based on their hash code values.

Parameters

Return

boolean: True if the hash codes are equal and false if they are not equal.

Example

use Libraries.Language.Object
use Libraries.Language.Types.Text
Object o
Text t
boolean result = o:Equals(t)

Exit()

This action tells the game to close at the end of the next iteration of the main loop. It is called automatically by the Game class's Exit action.

GetConfiguration()

Returns the WebConfiguration in use by the application.

Return

Libraries.Game.WebConfiguration:

GetHashCode()

This action gets the hash code for an object.

Return

integer: The integer hash code of the object.

Example

Object o
integer hash = o:GetHashCode()

GetWebOperatingSystem()

Returns the operating system the web application is running on.

Return

text:

Log(text message)

This action outputs a message to the developer console in the web browser.

Parameters

  • text message: The message to print to the developer console.

Example

use Libraries.Game.Game
use Libraries.Game.GameStateManager
use Libraries.Game.WebApplication

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        // Get the WebApplication class from the GameStateManager.
        // Note that this code will crash if the application isn't running on the web,
        // because we aren't double-checking to make sure the application is a WebApplication first.
        GameStateManager manager
        WebApplication app = cast(WebApplication, manager:GetApplication())
        app:Log("Hello world!")
    end
end

SaveImageToDownloads(Libraries.Game.Graphics.PixelMap image, text fileName)

This action saves the provided PixelMap as a PNG which is downloaded into the user's Downloads folder. The file will be saved using the given name (which should not include the file extension).

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Graphics.Drawable
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.PixelMap
use Libraries.Interface.Events.ScreenshotListener
use Libraries.Interface.Events.ScreenshotEvent
use Libraries.Game.GameStateManager
use Libraries.Game.Application
use Libraries.Game.WebApplication

class Main is Game, ScreenshotListener

    action Main
        StartGame()
    end

    action CreateGame
        // Register this class to receive screenshot events.
        AddScreenshotListener(me)

        // Add a pattern to the screen. The actual pattern drawn here isn't important, it's just something to appear in our screenshot.
        integer i = 0
        Color color
        repeat while i < 10
            Drawable drawable
            drawable:LoadFilledCircle(50, color:CustomColor(1.0 - i / 10.0, 0.5, 1 / 1.0, 1.0))
            drawable:SetPosition(100 * (i mod 2), 100 * (i / 2))
            Add(drawable)
            i = i + 1
        end

        // Tell the Game to screenshot the next frame of animation that's drawn.
        Screenshot()
    end

    // This gets called once the screenshot is taken.
    action OnScreenshot(ScreenshotEvent event)
        PixelMap screenshot = event:GetScreenshot()

        // Get the Application, make sure we're on the web, then save our screenshot to the Downloads folder.
        GameStateManager manager
        Application app = manager:GetApplication()
        if app is WebApplication
            WebApplication webApp = cast(WebApplication, app)
            webApp:SaveImageToDownloads(screenshot, "MyScreenshot")
        end
    end
end

SetConfiguration(Libraries.Game.WebConfiguration config)

Sets the WebConfiguration to be used by the application during the main loop.

Parameters

Setup(Libraries.Game.Game game)

Sets up the application and starts the main application loop.

Parameters