Libraries.Curriculum.TurtleProgram.TurtleGame Documentation

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

Actions Documentation

Add(Libraries.Game.Graphics.DirectionalLight light)

This action will add a DirectionalLight to the currently active Layer3D.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Graphics.Model
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.AmbientLight
use Libraries.Game.Graphics.DirectionalLight

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color

        Model box
        box:LoadBox(2, 2, 2, color:Teal())
        Add(box)

        AmbientLight ambient
        ambient:SetColor(0.4, 0.4, 0.4, 1)
        SetAmbientLight(ambient)

        DirectionalLight light
        light:SetColor(0.8, 0.8, 0.8, 1)
        light:SetDirection(1, -2, 1)
        Add(light)
    end

end

Add(Libraries.Interface.Item2D item)

The Add action will add an item to the Game. More specifically, the item will be added to the current default Layer2D. This will make the game handle the item for many tasks. For example, adding a Drawable will make it draw on the screen.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Graphics.Drawable

class Main is Game
    Drawable bunny

    action Main
        StartGame()
    end

    action CreateGame
        bunny:Load("Images/Rabbit.png")
        Add(bunny)
    end
end

Add(Libraries.Game.Graphics.PointLight light)

This action will add a PointLight to the currently active Layer3D.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Graphics.Model
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.AmbientLight
use Libraries.Game.Graphics.PointLight

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color

        Model box
        box:LoadBox(2, 2, 2, color:Teal())
        Add(box)

        AmbientLight ambient
        ambient:SetColor(0.4, 0.4, 0.4, 1)
        SetAmbientLight(ambient)

        PointLight light
        light:SetColor(0.8, 0.8, 0.8, 1)
        light:SetPosition(4, 3, -2)
        light:SetIntensity(30)
        Add(light)
    end

end

Add(Libraries.Interface.Item3D item)

The Add action will add an item to the Game. More specifically, the item will be added to the current default Layer3D. This will make the game handle the item for many tasks. For example, adding a Model will make it draw on the screen.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Graphics.Model

class Main is Game
    Model car

    action Main
        StartGame()
    end

    action CreateGame
        car:Load("sedan.g3db")
        Add(car)
    end
end

AddCollisionListener(Libraries.Interface.Events.CollisionListener2D listener)

Adds a collision listener to the game that will listen for collisions between 2D game objects that have been flagged as collidable. This listener can respond to collisions by implementing the BeginCollision and FinishCollision actions.

Parameters

Example

use Libraries.Game.Game
use Libraries.Interface.Item2D
use Libraries.Interface.Events.CollisionListener2D
use Libraries.Interface.Events.CollisionEvent2D

class Main is Game, CollisionListener2D

    Item2D item1
    Item2D item2

    action Main
        StartGame()
    end

    action CreateGame
        AddCollisionListener(me)
        item1:SetCollidable(true)
        item2:SetCollidable(true)
    end
    
    action BeginCollision(CollisionEvent2D event)

    end

    action FinishCollision(CollisionEvent3D event)

    end

end

AddCollisionListener(Libraries.Interface.Events.CollisionListener3D listener)

Adds a collision listener to the game that will listen for collisions between 3D game objects that have been flagged as collidable. This listener can respond to collisions by implementing the BeginCollision and FinishCollision actions.

Parameters

Example

use Libraries.Game.Game
use Libraries.Interface.Item3D
use Libraries.Interface.Events.CollisionListener3D
use Libraries.Interface.Events.CollisionEvent3D

class Main is Game, CollisionListener3D

    Item3D item1
    Item3D item2

    action Main
        StartGame()
    end

    action CreateGame
        AddCollisionListener(me)
        item1:SetCollidable(true)
        item2:SetCollidable(true)
    end
    
    action BeginCollision(CollisionEvent3D event)

    end

    action FinishCollision(CollisionEvent3D event)

    end

end

AddControlActivationListener(Libraries.Interface.Events.ControlActivationListener listener)

AddFocusListener(Libraries.Interface.Events.FocusListener listener)

This action adds a FocusListener to the Game. Whenever the focus changes, the FocusListener will be informed via a FocusEvent.

Parameters

AddGestureListener(Libraries.Interface.Events.GestureListener listener)

This action adds a GestureListener to the Game. The gesture listener will be notified when the user performs a gesture on mobile devices, so long as the event is not handled by any items in the layers.

Parameters

Example

use Libraries.Game.Game
use Libraries.Interface.Events.GestureListener

class Main is Game

    GestureListener listener

    action Main
        StartGame()
    end

    action CreateGame
        AddGestureListener(listener)
    end
    
end

AddInputTable(Libraries.Game.InputTable table)

This action adds an InputTable to the Game. If at any point the currently focused Item has an input group that matches the identifier of the table, the table will be used to trigger Behaviors.

Parameters

AddKeyboardListener(Libraries.Interface.Events.KeyboardListener listener)

This action adds a KeyboardListener to the Game. The listener will be notified of keys being pressed and released.

Parameters

Example

use Libraries.Game.Game
use Libraries.Interface.Events.KeyboardListener

class Main is Game

    KeyboardListener listener

    action Main
        StartGame()
    end

    action CreateGame
        AddKeyboardListener(listener)
    end
    
end

AddLayer(integer index, Libraries.Game.Layer layer)

This action will add the given Layer to the Game at the given index. Layers are handled (e.g. updated, drawn, etc.) in the order they're added, starting at index 0 with additional layers placed at higher indices.

Parameters

  • integer index: The index to place the Layer at.
  • Libraries.Game.Layer: The Layer to be added to the Game. use Libraries.Game.Game use Libraries.Game.Layer2D class Main is Game action Main StartGame() end action CreateGame // This will add the layer at index 0, making it the first layer drawn. Layer2D layer AddLayer(0, layer) end action Update(number seconds) end end

AddLayer(Libraries.Game.Layer layer)

This action will add a new Layer to the Game. It will be added on top of all other layers currently in the game.

Parameters

  • Libraries.Game.Layer: The Layer to be added to the Game. use Libraries.Game.Game use Libraries.Game.Layer2D class Main is Game action Main StartGame() end action CreateGame Layer2D layer AddLayer(layer) end action Update(number seconds) end end

AddMenuChangeListener(Libraries.Interface.Events.MenuChangeListener listener)

AddMouseListener(Libraries.Interface.Events.MouseListener listener)

This action adds a MouseListener to the Game. The mouse listener will be notified of mouse buttons being clicked and released, so long as the event is not handled by any listeners in the layers.

Parameters

Example

use Libraries.Game.Game
use Libraries.Interface.Events.MouseListener

class Main is Game

    MouseListener listener

    action Main
        StartGame()
    end

    action CreateGame
        AddMouseListener(listener)
    end
    
end

AddMouseMovementListener(Libraries.Interface.Events.MouseMovementListener listener)

This action adds a MouseMovementListener to the Game. The listener will be notified of mouse movement and dragging, so long as the event is not handled by any listeners in the layers.

Parameters

Example

use Libraries.Game.Game
use Libraries.Interface.Events.MouseMovementListener

class Main is Game

    MouseMovementListener listener

    action Main
        StartGame()
    end

    action CreateGame
        AddMouseMovementListener(listener)
    end
    
end

AddMouseWheelListener(Libraries.Interface.Events.MouseWheelListener listener)

This action adds a MouseWheelListener to the Game. The listener will be notified of mouse wheel scrolling, so long as the event is not handled by any listeners in the layers.

Parameters

Example

use Libraries.Game.Game
use Libraries.Interface.Events.MouseWheelListener

class Main is Game

    MouseWheelListener listener

    action Main
        StartGame()
    end

    action CreateGame
        AddMouseWheelListener(listener)
    end
    
end

AddResizeListener(Libraries.Interface.Events.ResizeListener listener)

This action adds a ResizeListener to the Game. The listener will be notified when the size of the Game rendering space changes size, such as a window being resized or made fullscreen, or a phone rotating orientation.

Parameters

Example

use Libraries.Game.Game
use Libraries.Interface.Events.ResizeListener

class Main is Game

    ResizeListener listener

    action Main
        StartGame()
    end

    action CreateGame
        AddResizeListener(listener)
    end
    
end

AddScreenshotListener(Libraries.Interface.Events.ScreenshotListener listener)

This action adds a ScreenshotListener to the Game. When a screenshot is taken using the Game's Screenshot action, the listener will be informed via a ScreenshotEvent.

Parameters

AddSelectionListener(Libraries.Interface.Events.SelectionListener listener)

This action adds a SelectionListener to the Game. Whenever a Selection is changed, the SelectionListener will be informed via a SelectionEvent.

Parameters

AddTabChangeListener(Libraries.Interface.Events.TabChangeListener listener)

AddTextChangeListener(Libraries.Interface.Events.TextChangeListener listener)

This action adds a TextChangeListener to the Game. When text is changed (such as in a TextBox) the TextChangeListener will be informed via a TextChangeEvent.

Parameters

AddTextInputListener(Libraries.Interface.Events.TextInputListener listener)

This action adds a TextInputListener to the Game. The listener will be notified when the Game receives textual input from the keyboard.

Parameters

Example

use Libraries.Game.Game
use Libraries.Interface.Events.TextInputListener

class Main is Game

    TextInputListener listener

    action Main
        StartGame()
    end

    action CreateGame
        AddTextInputListener(listener)
    end
    
end

AddTouchListener(Libraries.Interface.Events.TouchListener listener)

This action adds a TouchListener to the Game. The touch listener will be notified when the user interacts with a touch screen, so long as the event is not handled by any items in the layers.

Parameters

Example

use Libraries.Game.Game
use Libraries.Interface.Events.TouchListener

class Main is Game

    TouchListener listener

    action Main
        StartGame()
    end

    action CreateGame
        AddTouchListener(listener)
    end
    
end

AddTreeChangeListener(Libraries.Interface.Events.TreeChangeListener listener)

AddWindowFocusListener(Libraries.Interface.Events.WindowFocusListener listener)

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)

ContinueGame()

This action is used by the Game to regularly handle core engine processes. It is automatically called by the Game when necessary, and should never be used by users.

CreateGame()

EnablePhysics2D(boolean flag)

This action will return a new AmbientLight object which contains the ambient lighting data of the currently active Layer3D.

Parameters

  • boolean flag

Example

use Libraries.Game.Game
use Libraries.Game.Graphics.Model
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.AmbientLight
use Libraries.Game.Graphics.DirectionalLight

class Main is Game

    AmbientLight myLight

    action Main
        StartGame()
    end

    action CreateGame
        Color color

        Model box
        box:LoadBox(2, 2, 2, color:Teal())
        Add(box)

        AmbientLight ambient
        ambient:SetColor(0.4, 0.4, 0.4, 1)
        SetAmbientLight(ambient)

        DirectionalLight light
        light:SetColor(0.8, 0.8, 0.8, 1)
        light:SetDirection(1, -2, 1)
        Add(light)

        myLight = GetAmbientLight()
    end

end

EnablePhysics3D(boolean flag)

This action will remove the ambient lighting from the currently active Layer3D.

Parameters

  • boolean flag

Example

use Libraries.Game.Game
use Libraries.Game.Graphics.Model
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.AmbientLight
use Libraries.Game.Graphics.PointLight

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color

        Model box
        box:LoadBox(2, 2, 2, color:Teal())
        Add(box)

        AmbientLight ambient
        ambient:SetColor(0.4, 0.4, 0.4, 1)
        SetAmbientLight(ambient)

        PointLight light
        light:SetColor(0.8, 0.8, 0.8, 1)
        light:SetPosition(4, 3, -2)
        light:SetIntensity(30)
        Add(light)

        RemoveAmbientLight()
    end

end

EnableResizing(boolean resize)

This action enables or disables resizing the game window by dragging the edges of the screen. Passing a value of true enables it, a value of false disables it. Resizing is disabled by default. It is only relevant for games which are run on desktops. This action should be called before calling StartGame().

Parameters

  • boolean resize: Whether or not the game window should be resizable.

Example

use Libraries.Game.Game

class Main is Game

    action Main
        EnableResizing(true)
        StartGame()
    end
end

EnableTextureAutoResizing(boolean resize)

This action enables or disables auto resizing of textures if the game window is resized. Passing a value of true enables it, a value of false disables it. Texture auto resizing is enabled by default. This action should be called before calling StartGame(). This option is only relevant on desktop platforms.

Parameters

  • boolean resize: Whether or not to automatically resize textures on window resizing.

Example

use Libraries.Game.Game

class Main is Game

    action Main
        EnableTextureAutoResizing(false)
        StartGame()
    end
end

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()

The Exit action is used to tell the Game class to close the application after it completes the current iteration of the main loop.

Example

use Libraries.Game.Game

class Main is Game

    number timer = 0

    action Main
        StartGame()
    end

    action Update(number time)
        timer = timer + time
        if timer > 3
            Exit()
            output "Exiting the game!"
        end
    end
    
end

FindItem2DByName(text name)

This action finds the first Item2D that has been added to the Game with the given name and returns it. If no Item2D with the given name can be found, this action returns undefined instead.

Parameters

  • text name: The name of the Item to be found.

Return

Libraries.Interface.Item2D: The first Item2D added to the Game which has the given name, or undefined if no such item can be found.

FindItem3DByName(text name)

This action finds the first Item3D that has been added to the Game with the given name and returns it. If no Item3D with the given name can be found, this action returns undefined instead.

Parameters

  • text name: The name of the Item to be found.

Return

Libraries.Interface.Item3D: The first Item3D added to the Game which has the given name, or undefined if no such item can be found

FocusWindow()

This action asks the operating system to give the main application window the focus. This only works on desktop platforms - on other platforms, this call is ignored.

GetAccessibility()

GetAmbientLight()

This action will return a new AmbientLight object which contains the ambient lighting data of the currently active Layer3D.

Return

Libraries.Game.Graphics.AmbientLight: The AmbientLight of the currently active Layer3D.

Example

use Libraries.Game.Game
use Libraries.Game.Graphics.Model
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.AmbientLight
use Libraries.Game.Graphics.DirectionalLight

class Main is Game

    AmbientLight myLight

    action Main
        StartGame()
    end

    action CreateGame
        Color color

        Model box
        box:LoadBox(2, 2, 2, color:Teal())
        Add(box)

        AmbientLight ambient
        ambient:SetColor(0.4, 0.4, 0.4, 1)
        SetAmbientLight(ambient)

        DirectionalLight light
        light:SetColor(0.8, 0.8, 0.8, 1)
        light:SetDirection(1, -2, 1)
        Add(light)

        myLight = GetAmbientLight()
    end

end

GetAndroidConfiguration()

This action will return the game's configuration for Android devices.

Return

Libraries.Game.AndroidConfiguration: The current AndroidConfiguration.

Example

use Libraries.Game.Game
use Libraries.Game.AndroidConfiguration

class Main is Game

    action Main
        AndroidConfiguration configuration = GetAndroidConfiguration()
        configuration:defaultOrientation = configuration:PORTRAIT
        StartGame()
    end

end

GetAvailableResolutions()

This action will return an Array of ScreenResolution objects that describe available screen resolutions for this desktop platform. If this action is called on a non-desktop platform, the returned array will be undefined.

Return

Libraries.Containers.Array: An array of ScreenResolutions that can be used by the desktop display.

Example

use Libraries.Game.Game
use Libraries.Game.ScreenResolution
use Libraries.Containers.Array

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Array<ScreenResolution> array = GetAvailableResolutions()
        output "The following resolutions are supported by the monitor:"

        integer counter = 0
        repeat while counter < array:GetSize()
            ScreenResolution resolution = array:Get(counter)

            output ""
            output "Resolution #" + counter
            output "Dimensions: " + resolution:GetWidth() + " x " + resolution:GetHeight()
            output "Refresh Rate: " + resolution:GetFrequency()
            output "Bits per Pixel: " + resolution:GetBitsPerPixel()
            output "Supports Fullscreen: " + resolution:IsFullscreen()

            counter = counter + 1
        end
    end
end

GetCamera2D()

This action will return the camera that is a part of the current Layer2D.

Return

Libraries.Game.Graphics.Camera: The Camera in use by the currently active Layer2D.

Example

use Libraries.Game.Game
use Libraries.Game.Graphics.Camera

class Main is Game

    Camera camera = undefined

    action Main
        StartGame()
    end

    action CreateGame
        camera = GetCamera2D()
    end

end

GetCamera3D()

This action will return the camera that is a part of the current Layer3D.

Return

Libraries.Game.Graphics.Camera: The Camera in use by the currently active Layer3D.

Example

use Libraries.Game.Game
use Libraries.Game.Graphics.Camera

class Main is Game

    Camera camera = undefined

    action Main
        StartGame()
    end

    action CreateGame
        camera = GetCamera3D()
    end

end

GetClipboard()

Not all implementations support a clipboard, but all displays support the operations so that they can be called everywhere. If an implementation supports a clipboard, the appopriate system mechanisms are handled automatically. The example here would output whatever is currently on the clipboard.

Return

text: this action returns text from the system clipboard.

Example

use Libraries.Game.Game

class Main is Game
    action Main
        StartGame()
    end

    action CreateGame
        output GetClipboard()
    end

    action Update(number seconds)
    end
end

GetCurrentLayer2D()

This action will return the current Layer2D which will be used during actions that require a Layer if the user does not specify one, e.g., using the Add(Item2D) action.

Return

Libraries.Game.Layer2D: The currently active Layer2D.

Example

use Libraries.Game.Game
use Libraries.Game.Layer2D

class Main is Game

    Layer2D activeLayer = undefined

    action Main
        StartGame()
    end

    action CreateGame
        activeLayer = GetCurrentLayer2D()
    end

end

GetCurrentLayer3D()

This action will return the current Layer3D which will be used during actions that require a Layer if the user does not specify one, e.g., using the Add(Item3D) action.

Return

Libraries.Game.Layer3D: The currently active Layer3D.

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D

class Main is Game

    Layer3D activeLayer = undefined

    action Main
        StartGame()
    end

    action CreateGame
        activeLayer = GetCurrentLayer3D()
    end

end

GetDefaultInputTable()

GetDesktopConfiguration()

This action will return the game's configuration for desktop platforms.

Return

Libraries.Game.DesktopConfiguration: The current DesktopConfiguration.

Example

use Libraries.Game.Game
use Libraries.Game.DesktopConfiguration

class Main is Game

    action Main
        DesktopConfiguration configuration = GetDesktopConfiguration()
        output "The default width and height of the Game are " + configuration:width + ", " + configuration:height
        StartGame()
    end

end

GetDesktopResolution()

This action will return a ScreenResolution object that describes the screen resolution currently in use by the desktop (independent of the resolution used by the game). This is only effective on desktop platforms - using this action on non-desktop platforms will return undefined.

Return

Libraries.Game.ScreenResolution: A ScreenResoluton object describing the desktop's resolution.

Example

use Libraries.Game.Game
use Libraries.Game.ScreenResolution

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        ScreenResolution resolution = GetDesktopResolution()
        output "The dimensions of the desktop's resolution is " + resolution:GetWidth() + " x " + resolution:GetHeight()
    end
end

GetDialogLayerPool()

This action returns the pool of DialogLayers usable by the Game. This should never be called manually -- instead, when using Dialogs, use the Show() and Hide() calls to display or close the Dialog. This action is used internally by the Game engine.

Return

Libraries.Game.DialogLayerPool:

GetDirection()

Return

text

GetDirectionalLight(integer index)

This action will get a DirectionalLight from the currently active Layer3D, which is stored at the given index inside the layer. If there are no DirectionalLights within the layer, or if the index is out of bounds, then an error will be thrown.

Parameters

  • integer index: The index to retrieve the DirectionalLight from.

Return

Libraries.Game.Graphics.DirectionalLight:

Example

use Libraries.Game.Game
use Libraries.Game.Graphics.Model
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.AmbientLight
use Libraries.Game.Graphics.DirectionalLight

class Main is Game

    DirectionalLight myLight

    action Main
        StartGame()
    end

    action CreateGame
        Color color

        Model box
        box:LoadBox(2, 2, 2, color:Teal())
        Add(box)

        AmbientLight ambient
        ambient:SetColor(0.4, 0.4, 0.4, 1)
        SetAmbientLight(ambient)

        DirectionalLight light
        light:SetColor(0.8, 0.8, 0.8, 1)
        light:SetDirection(1, -2, 1)
        Add(light)

        myLight = GetDirectionalLight(0)
    end

end

GetDirectionalLights()

This action will return an iterator containing all of the DirectionalLight objects stored within the currently active Layer3D.

Return

Libraries.Containers.Iterator: An Iterator containing all DirectionalLights on the currently active Layer3D.

GetEditManager()

This action gets the default EditManager from the system.

Return

Libraries.Interface.Undo.EditManager: The EditManager

Example

use Libraries.Game.Game
use Libraries.Interface.Undo.EditManager

class Main is Game
    action Main
        StartGame()
    end

    action CreateGame
        EditManager edits = GetEditManager()
    end

    action Update(number seconds)
    end
end

GetFirstLetterNavigationTime()

This action finds the first Item3D that has been added to the Game with the given name and returns it. If no Item3D with the given name can be found, this action returns undefined instead.

Return

number: The first Item3D added to the Game which has the given name, or undefined if no such item can be found

GetFocus()

This action returns the current Item that is focused.

Return

Libraries.Interface.Item: The currently focused Item.

GetFocusManager()

This action returns the FocusManager to be used for the Game. The FocusManager is responsible for moving focus between Items, which is essential for GUIs to function correctly.

Return

Libraries.Game.FocusManager:

GetFontManager()

This action returns the FontManager in use by the Game. The FontManager is responsible for loading and storing font information.

Return

Libraries.Game.Graphics.Fonts.FontManager:

GetGameName()

This action returns the name of the game displayed at the top of the window. The default name is "Game".

Return

text: The name displayed on the Game window.

Example

use Libraries.Game.Game

class Main is Game

    action Main
        output "The default name is " + GetGameName()
        SetGameName("Mariachi Band Simulator 3000")
        output "The new name is " + GetGameName()
        StartGame()
    end
end

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()

GetInputTable(text key)

This action retrieves an InputTable with the matching identifier from the Game (if there is one). If there is no InputTable with this identifier, the action will return undefined.

Parameters

  • text key

Return

Libraries.Game.InputTable:

GetInterfaceOptions()

This action returns the InterfaceOptions currently being used by the game. The InterfaceOptions provide default colors and properties for Controls in the game.

Return

Libraries.Interface.Options.InterfaceOptions: The current InterfaceOptions in use by the game.

Example

use Libraries.Game.Game
use Libraries.Game.Graphics.Color
use Libraries.Interface.Options.InterfaceOptions

class Main is Game

    Color color

    action Main
        StartGame()
    end

    action CreateGame
        InterfaceOptions options = GetInterfaceOptions()

        // Once we have the options, we can modify them to adjust how our Controls appear by default.
        options:SetButtonBackgroundColor(color:Pink())
    end
end

GetInterfaceScale()

The GetInterfaceScale action returns the scale of the user interface. Larger scaling values make each interface component larger. When the interface is scaled in this way, components that can be re-rendered at a higher resolution (such as fonts) will do so. Note that this represents the standard scale in use by the default 2D layer, and it will not necessarily reflect the scale of every single component.

Return

number: The current interface rendering scale.

Example

use Libraries.Game.Game
use Libraries.Interface.Layouts.FlowLayout
use Libraries.Interface.Controls.Button

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        FlowLayout layout
        SetLayout(layout)

        Button button1
        button1:SetName("My Button")
        Add(button1)

        output "The default interface scale is " + GetInterfaceScale()
    end
end

GetLayerIterator()

This action will return an iterator containing the Game's layers. The first Layer in the iterator will be the bottom Layer, and each following Layer in the iterator will be the Layer on top of the previous one.

Return

Libraries.Containers.Iterator: An Iterator containing all of the Layers added to the Game.

Example

use Libraries.Game.Game
use Libraries.Game.Graphics.OrthographicCamera

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        OrthographicCamera camera
        SetCamera2D(camera)
    end

end

GetLayout()

The GetLayout action returns the layout that has been applied to the default Layer2D.

Return

Libraries.Interface.Layouts.Layout:

Example

use Libraries.Game.Game
use Libraries.Interface.Layouts.Layout
use Libraries.Interface.Layouts.FlowLayout
use Libraries.Interface.Controls.Button

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        FlowLayout layout
        SetLayout(layout)

        Button button1
        button1:SetName("My Button")
        Add(button1)

        Layout currentLayout = GetLayout()
    end
end

GetPointLight(integer index)

This action will get a PointLight from the currently active Layer3D, which is stored at the given index inside the layer. If there are no PointLights within the layer, or if the index is out of bounds, then an error will be thrown.

Parameters

  • integer index: The index to retrieve the PointLight from.

Return

Libraries.Game.Graphics.PointLight:

Example

use Libraries.Game.Game
use Libraries.Game.Graphics.Model
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.AmbientLight
use Libraries.Game.Graphics.PointLight

class Main is Game

    PointLight myLight

    action Main
        StartGame()
    end

    action CreateGame
        Color color

        Model box
        box:LoadBox(2, 2, 2, color:Teal())
        Add(box)

        AmbientLight ambient
        ambient:SetColor(0.4, 0.4, 0.4, 1)
        SetAmbientLight(ambient)

        PointLight light
        light:SetColor(0.8, 0.8, 0.8, 1)
        light:SetPosition(4, 3, -2)
        light:SetIntensity(30)
        Add(light)

        myLight = GetPointLight(0)
    end

end

GetPointLights()

This action will return an iterator containing all of the PointLight objects stored within the currently active Layer3D.

Return

Libraries.Containers.Iterator: An Iterator containing all PointLights on the currently active Layer3D.

GetSceneManager()

This action returns the manager used to save and load scenes in the Game.

Return

Libraries.Game.Scenes.SceneManager:

GetScreenHeight()

The GetScreenHeight action will return the height of the screen as an integer.

Return

integer: The height of the screen.

Example

use Libraries.Game.Game

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        output GetScreenHeight()
    end
end

GetScreenResolution()

This action will return the current ScreenResolution being used by the game engine. This is only effective on desktop platforms - on non-desktop platforms, this will return undefined instead.

Return

Libraries.Game.ScreenResolution:

Example

use Libraries.Game.Game
use Libraries.Game.ScreenResolution

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        ScreenResolution resolution = GetScreenResolution()
        output "The default resolution's dimensions are " + resolution:GetWidth() + " x " + resolution:GetHeight()
    end
end

GetScreenWidth()

The GetScreenWidth action will return the width of the screen as an integer.

Return

integer: The width of the screen.

Example

use Libraries.Game.Game

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        output GetScreenWidth()
    end
end

GetSecondsBetweenFrames()

GetSecondsBetweenFrames will return the number of seconds that has passed between the current frame and the previous one. Frames are the still images drawn on the screen in rapid succession to make the images appear to move. Note that the value from this field is approximately the same value as the parameter in the Update action.

Return

number: How many seconds have passed since the previous frame.

Example

use Libraries.Game.Game

class Main is Game

    action Main
        StartGame()
    end

    action Update(number time)
        output "Seconds since last frame: " + GetSecondsBetweenFrames()
    end
end

GetShaderManager()

Set the dimensions of the screenshot. If the values are 0, it'll default to a shot of the whole screen when processed.

Return

Libraries.Game.Graphics.Shaders.ShaderManager:

GetSharedTextureManager()

It's fine if this is undefined, in that case it'll just go through the listeners attached to the input.

Return

Libraries.Game.Graphics.SharedTextureManager:

GetSimulationThreshold2D()

The SetSkybox action will set the currently active Layer3D to use the given Skybox.

Return

number:

Example

use Libraries.Game.Game
use Libraries.Game.Graphics.Skybox

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Skybox skybox
        // Assuming we have a folder named "skybox" containing our six images.
        skybox:Load("skybox/right.jpg", "skybox/left.jpg", "skybox/top.jpg", "skybox/bottom.jpg", "skybox/front.jpg", "skybox/back.jpg")
        SetSkybox(skybox)
    end

end

GetSkybox()

The GetSkybox action will return the Skybox in use by the currently active Layer3D. By default, a Layer3D does not start with a Skybox, so using this on a Layer3D that hasn't had a Skybox assigned to it will return undefined.

Return

Libraries.Game.Graphics.Skybox: The Skybox in use by the current Layer3D.

Example

use Libraries.Game.Game
use Libraries.Game.Graphics.Skybox

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Skybox skybox
        // Assuming we have a folder named "skybox" containing our six images.
        skybox:Load("skybox/right.jpg", "skybox/left.jpg", "skybox/top.jpg", "skybox/bottom.jpg", "skybox/front.jpg", "skybox/back.jpg")
        SetSkybox(skybox)

        // We can get the Skybox back from the layer using GetSkybox().
        Skybox currentSkybox = GetSkybox()
    end

end

GetWebConfiguration()

This action will return the game's configuration for web platforms.

Return

Libraries.Game.WebConfiguration: The current WebConfiguration.

Example

use Libraries.Game.Game
use Libraries.Game.WebConfiguration

class Main is Game

    action Main
        WebConfiguration configuration = GetWebConfiguration()
        configuration:capFramesPerSecond = true
        StartGame()
    end

end

GetX()

Return

integer

GetY()

Return

integer

InitializeLayers()

This action sets the game to use the default layers. The default layers consist of a single 3D layer, with a single 2D layer on top of it. This action is automatically called by the Game engine during StartGame. Users may use it again to "reset" the layers to default, but generally users will not need to use this action directly.

IsColliding()

This allows us to know if collisions are on or off for the layer.

Return

boolean:

IsWindowFocused()

This action determines whether or not the main application window has the focus on desktop platforms. On non-desktop platforms, this always returns false.

Return

boolean:

IsWindowMaximized()

On desktop platforms, this action returns true if the application is in a maximized window, or false otherwise. On other platforms, this always returns false.

Return

boolean: True if the window is maximized, false otherwise.

IsWindowMinimized()

On desktop platforms, this action returns true if the application is currently minimized, or false otherwise. On other platforms, this always returns false.

Return

boolean: True if the window is maximized, false otherwise.

LoadScene(Libraries.Game.Scenes.Scene scene)

This loads a scene file into the game.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Scenes.Scene
use Libraries.System.File

class Main is Game
    action Main
        StartGame()
    end

    action CreateGame
        Scene scene
        File file
        file:SetPath("Scenes/Scene.qs")
        scene:Load(file)
        LoadScene(scene)
    end

    action Update(number seconds)
    end
end

LoadScene(text path)

This loads a scene file into the game. This is a helper action for loading a scene.

Parameters

  • text path

Example

use Libraries.Game.Game
use Libraries.Game.Scenes.Scene
use Libraries.System.File

class Main is Game
    action Main
        StartGame()
    end

    action CreateGame
        LoadScene("Scenes/Scene.qs")
    end

    action Update(number seconds)
    end
end

LoadScene(Libraries.System.File file)

This loads a scene file into the game.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Scenes.Scene
use Libraries.System.File

class Main is Game
    action Main
        StartGame()
    end

    action CreateGame
        File file
        file:SetPath("Scenes/Scene.qs")
        LoadScene(file)
    end

    action Update(number seconds)
    end
end

MoveForward()

OnExit()

The OnExit action is called when the Game is about to close, either because the Exit action was called or because the user requested it (for example, by attempting to close the window on desktop platforms). The action must return a boolean value representing whether or not the application should proceed to shut down. If the returned value is true, the application will shut down. If it is false, the program will continue running instead. Users should always make sure that it is possible for OnExit to return true in some cases to allow the user to close the program. This action doesn't prevent the Game from shutting down on all platforms. For example, mobile devices typically don't allow an application to keep itself open after a close has been requested.

Return

boolean: True if the Game should be allowed to close, false if the Game should continue running.

Example

use Libraries.Game.Game

class Main is Game
    integer countdown = 3

    action Main
        StartGame()
    end

    action OnExit returns boolean
        if countdown <= 0
            return true
        end
        output "Countdown: " + countdown
        countdown = countdown - 1
        return false
    end
end

OutputLines()

PenDown()

PenUp()

Remove(Libraries.Game.Graphics.PointLight light)

This action will remove a PointLight from the currently active Layer3D.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Graphics.Model
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.AmbientLight
use Libraries.Game.Graphics.PointLight

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color

        Model box
        box:LoadBox(2, 2, 2, color:Teal())
        Add(box)

        AmbientLight ambient
        ambient:SetColor(0.4, 0.4, 0.4, 1)
        SetAmbientLight(ambient)

        PointLight light
        light:SetColor(0.8, 0.8, 0.8, 1)
        light:SetPosition(4, 3, -2)
        light:SetIntensity(30)
        Add(light)

        Remove(light)
    end

end

Remove(Libraries.Game.Graphics.DirectionalLight light)

This action will remove a DirectionalLight from the currently active Layer3D.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Graphics.Model
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.AmbientLight
use Libraries.Game.Graphics.DirectionalLight

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color

        Model box
        box:LoadBox(2, 2, 2, color:Teal())
        Add(box)

        AmbientLight ambient
        ambient:SetColor(0.4, 0.4, 0.4, 1)
        SetAmbientLight(ambient)

        DirectionalLight light
        light:SetColor(0.8, 0.8, 0.8, 1)
        light:SetDirection(1, -2, 1)
        Add(light)

        Remove(light)
    end

end

Remove(Libraries.Interface.Item3D item)

The Remove action will remove an item that was put into the game using the Add action. More specifically, the item will be removed from the current default Layer3D. The game will no longer handle removed items - for example, removing a Model will make the game engine stop drawing it.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Graphics.Model

class Main is Game
    Model car

    action Main
        StartGame()
    end

    action CreateGame
        car:Load("sedan.g3db")
        Add(car)

        // If we don't have this remove command, the bunny will draw.
        Remove(car)
    end
end

Remove(Libraries.Interface.Item2D item)

The Remove action will remove an item that was put into the game using the Add action. More specifically, the item will be removed from the current default Layer2D. The game will no longer handle removed items - for example, removing a Drawable will make the game engine stop drawing it.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Graphics.Drawable

class Main is Game
    Drawable bunny

    action Main
        StartGame()
    end

    action CreateGame
        bunny:Load("Images/Rabbit.png")
        Add(bunny)

        // If we don't have this remove command, the bunny will draw.
        Remove(bunny)
    end
end

RemoveAmbientLight()

This action will remove the ambient lighting from the currently active Layer3D.

Example

use Libraries.Game.Game
use Libraries.Game.Graphics.Model
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.AmbientLight
use Libraries.Game.Graphics.PointLight

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color

        Model box
        box:LoadBox(2, 2, 2, color:Teal())
        Add(box)

        AmbientLight ambient
        ambient:SetColor(0.4, 0.4, 0.4, 1)
        SetAmbientLight(ambient)

        PointLight light
        light:SetColor(0.8, 0.8, 0.8, 1)
        light:SetPosition(4, 3, -2)
        light:SetIntensity(30)
        Add(light)

        RemoveAmbientLight()
    end

end

RemoveCollisionListener(Libraries.Interface.Events.CollisionListener2D listener)

Removes a 2D collision listener from the game. This collision listener will no longer receive collision events from the game engine.

Parameters

Example

use Libraries.Game.Game
use Libraries.Interface.Item2D
use Libraries.Interface.Events.CollisionListener2D
use Libraries.Interface.Events.CollisionEvent2D

class Main is Game, CollisionListener2D

    Item2D item1
    Item2D item2

    action Main
        StartGame()
    end

    action CreateGame
        AddCollisionListener(me)
        item1:SetCollidable(true)
        item2:SetCollidable(true)

        RemoveCollisionListener(me)
    end
    
    action BeginCollision(CollisionEvent2D event)

    end

    action FinishCollision(CollisionEvent2D event)

    end

end

RemoveCollisionListener(Libraries.Interface.Events.CollisionListener3D listener)

Removes a 3D collision listener from the game. This collision listener will no longer receive collision events from the game engine.

Parameters

Example

use Libraries.Game.Game
use Libraries.Interface.Item3D
use Libraries.Interface.Events.CollisionListener3D
use Libraries.Interface.Events.CollisionEvent3D

class Main is Game, CollisionListener3D

    Item3D item1
    Item3D item2

    action Main
        StartGame()
    end

    action CreateGame
        AddCollisionListener(me)
        item1:SetCollidable(true)
        item2:SetCollidable(true)

        RemoveCollisionListener(me)
    end
    
    action BeginCollision(CollisionEvent3D event)

    end

    action FinishCollision(CollisionEvent3D event)

    end

end

RemoveControlActivationListener(Libraries.Interface.Events.ControlActivationListener listener)

RemoveFocusListener(Libraries.Interface.Events.FocusListener listener)

This action removes a FocusListener from the Game. The given FocusListener will no longer be informed of FocusEvents when the focus changes.

Parameters

RemoveGestureListener(Libraries.Interface.Events.GestureListener listener)

This action removes a GestureListener from the Game. The listener will no longer receive GestureEvents from the Game. If the given GestureListener is not a part of the Game, this action will have no effect.

Parameters

Example

use Libraries.Game.Game
use Libraries.Interface.Events.GestureListener

class Main is Game

    GestureListener listener

    action Main
        StartGame()
    end

    action CreateGame
        AddGestureListener(listener)

        RemoveGestureListener(listener)
    end
    
end

RemoveInputTable(text key)

This action removes the InputTable with the matching identifier from the Game (if there is one). If the InputTable is found, it will be returned - otherwise, the action returns undefined.

Parameters

  • text key

Return

Libraries.Game.InputTable:

RemoveKeyboardListener(Libraries.Interface.Events.KeyboardListener listener)

This action removes a KeyboardListener from the Game. The listener will no longer receive events for key presses and releases.

Parameters

Example

use Libraries.Game.Game
use Libraries.Interface.Events.KeyboardListener

class Main is Game

    KeyboardListener listener

    action Main
        StartGame()
    end

    action CreateGame
        AddKeyboardListener(listener)

        RemoveKeyboardListener(listener)
    end
    
end

RemoveLayer(integer index)

This action will remove the Layer stored in the Game at the given index within the internal layer array, where the first element (at index 0) of the array is the bottom layer, and further elements of the array are placed on top of previous elements.

Parameters

  • integer index: The index of the Layer to be removed. use Libraries.Game.Game use Libraries.Game.Layer2D class Main is Game action Main StartGame() end action CreateGame // This will remove the bottom Layer of the Game. RemoveLayer(0) end action Update(number seconds) end end

RemoveLayer(Libraries.Game.Layer layer)

This action will remove the given Layer from the Game.

Parameters

  • Libraries.Game.Layer: The Layer to be removed from the Game. use Libraries.Game.Game use Libraries.Game.Layer2D class Main is Game action Main StartGame() end action CreateGame Layer2D layer AddLayer(layer) RemoveLayer(layer) end action Update(number seconds) end end

RemoveMenuChangeListener(Libraries.Interface.Events.MenuChangeListener listener)

RemoveMouseListener(Libraries.Interface.Events.MouseListener listener)

This action removes a MouseListener from the Game. The mouse listener will no longer receive mouse events from the Game. If the given MouseListener was not part of the Game, then this will have no effect.

Parameters

Example

use Libraries.Game.Game
use Libraries.Interface.Events.MouseListener

class Main is Game

    MouseListener listener

    action Main
        StartGame()
    end

    action CreateGame
        AddMouseListener(listener)

        RemoveMouseListener(listener)
    end
    
end

RemoveMouseMovementListener(Libraries.Interface.Events.MouseMovementListener listener)

This action removes a MouseMovementListener from the Game. The listener will no longer receive events from the Game. If the given MouseMovementListener was not part of the Game, then this will have no effect.

Parameters

Example

use Libraries.Game.Game
use Libraries.Interface.Events.MouseMovementListener

class Main is Game

    MouseMovementListener listener

    action Main
        StartGame()
    end

    action CreateGame
        AddMouseMovementListener(listener)

        RemoveMouseMovementListener(listener)
    end
    
end

RemoveMouseWheelListener(Libraries.Interface.Events.MouseWheelListener listener)

This action removes a MouseWheelListener from the Game. The listener will no longer receive events from the Game. If the given MouseWheelListener is not part of the Game, then this will have no effect.

Parameters

Example

use Libraries.Game.Game
use Libraries.Interface.Events.MouseWheelListener

class Main is Game

    MouseWheelListener listener

    action Main
        StartGame()
    end

    action CreateGame
        AddMouseWheelListener(listener)

        RemoveMouseWheelListener(listener)
    end
    
end

RemoveResizeListener(Libraries.Interface.Events.ResizeListener listener)

This action removes a ResizeListener from the Game. The listener will no longer receive resize events.

Parameters

Example

use Libraries.Game.Game
use Libraries.Interface.Events.ResizeListener

class Main is Game

    ResizeListener listener

    action Main
        StartGame()
    end

    action CreateGame
        AddResizeListener(listener)

        RemoveResizeListener(listener)
    end
    
end

RemoveScreenshotListener(Libraries.Interface.Events.ScreenshotListener listener)

This action removes a ScreenshotListener from the Game. It will no longer receive ScreenshotEvents.

Parameters

RemoveSelectionListener(Libraries.Interface.Events.SelectionListener listener)

This action removes a SelectionListener from the Game. The SelectionListener will no longer be informed when Selections change.

Parameters

RemoveTabChangeListener(Libraries.Interface.Events.TabChangeListener listener)

RemoveTextChangeListener(Libraries.Interface.Events.TextChangeListener listener)

This action removes a TextChangeListener from the Game. It will no longer receive TextChangeEvents.

Parameters

RemoveTextInputListener(Libraries.Interface.Events.TextInputListener listener)

This action removes a TextInputListener from the Game. The listener will no longer receive events for text input from the keyboard.

Parameters

Example

use Libraries.Game.Game
use Libraries.Interface.Events.TextInputListener

class Main is Game

    TextInputListener listener

    action Main
        StartGame()
    end

    action CreateGame
        AddTextInputListener(listener)

        RemoveTextInputListener(listener)
    end
    
end

RemoveTouchListener(Libraries.Interface.Events.TouchListener listener)

This action removes a TouchListener from the Game. The listener will no longer receive TouchEvents from the Game. If the given TouchListener is not a part of the Game, this action will have no effect.

Parameters

Example

use Libraries.Game.Game
use Libraries.Interface.Events.TouchListener

class Main is Game

    TouchListener listener

    action Main
        StartGame()
    end

    action CreateGame
        AddTouchListener(listener)

        RemoveTouchListener(listener)
    end
    
end

RemoveTreeChangeListener(Libraries.Interface.Events.TreeChangeListener listener)

RemoveWindowFocusListener(Libraries.Interface.Events.WindowFocusListener listener)

RepeatMoveForward(integer steps)

Parameters

  • integer steps

SaveScene(Libraries.System.File file)

This action saves everything currently in the game to a Scene file, which it returns, and additionally saves this scene to disk.

Parameters

Return

Libraries.Game.Scenes.Scene: a scene file

SaveScene()

This action saves all of the items currently in the game to a Scene object, which can then be saved.

Return

Libraries.Game.Scenes.Scene: the Scene object.

Example


       use Libraries.Game.Game
       use Libraries.Game.Scenes.Scene
       use Libraries.System.File
       
       class Main is Game
           action Main
               StartGame()
           end
       
           action CreateGame
               LoadScene("Scenes/Scene.qs")

               //returns undefined if the item is not found
               Item2D player = FindItem2DByName("1: Girl")
           end
       
           action Update(number seconds)
           end
       end

Screenshot(Libraries.Interface.Events.ScreenshotListener callback)

This action instructs the Game to take a screenshot after the next frame of animation has been drawn. When the screenshot is taken, it will be stored in a PixelMap and sent to all ScreenshotListeners that have been registered in the Game. This action takes a screenshot of the entire window, then it informs the provided "callback" listener. After the callback has received the event, other ScreenshotListeners that have been added to the Game will also be notified.

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
        // 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.
        // Instead of registering this class as a listener, we can pass it directly here as a parameter.
        // The listener will be called back when the screenshot is taken.
        Screenshot(me)
    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

Screenshot(integer x, integer y, integer width, integer height, Libraries.Interface.Events.ScreenshotListener callback)

This action instructs the Game to take a screenshot after the next frame of animation has been drawn. When the screenshot is taken, it will be stored in a PixelMap and sent to all ScreenshotListeners that have been registered in the Game. This action takes a screenshot of the specified area of the window, then it informs the provided "callback" listener. After the callback has received the event, other ScreenshotListeners that have been added to the Game will also be notified.

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
        // 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.
        // With these parameters, we'll get just a section of the pattern we've drawn.
        // Instead of registering this class as a listener, we can pass it directly here as a parameter.
        // The listener will be called back when the screenshot is taken.
        Screenshot(50, 50, 150, 300, me)
    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

Screenshot()

This action instructs the Game to take a screenshot after the next frame of animation has been drawn. When the screenshot is taken, it will be stored in a PixelMap and sent to all ScreenshotListeners that have been registered in the Game. This action takes a screenshot of the entire window. You can use the other Screenshot definitions to capture only part of the window, or to provide a direct callback to handle the screenshot before the registered listeners.

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

Screenshot(integer x, integer y, integer width, integer height)

This action instructs the Game to take a screenshot after the next frame of animation has been drawn. When the screenshot is taken, it will be stored in a PixelMap and sent to all ScreenshotListeners that have been registered in the Game. This action takes a screenshot of the window within the given coordinates. You can use the other Screenshot definitions to automatically capture the whole window, or to provide a direct callback to handle the screenshot before the registered listeners.

Parameters

  • integer x
  • integer y
  • integer width
  • integer height

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.
        // With these parameters, we'll get just a section of the pattern we've drawn.
        Screenshot(50, 50, 150, 300)
    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

SetAccessibility(Libraries.Interface.Accessibility accessibilityManager)

SetAmbientLight(Libraries.Game.Graphics.AmbientLight light)

This action will set the ambient light on the currently active Layer3D.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Graphics.Model
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.AmbientLight
use Libraries.Game.Graphics.DirectionalLight

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color

        Model box
        box:LoadBox(2, 2, 2, color:Teal())
        Add(box)

        AmbientLight ambient
        ambient:SetColor(0.4, 0.4, 0.4, 1)
        SetAmbientLight(ambient)

        DirectionalLight light
        light:SetColor(0.8, 0.8, 0.8, 1)
        light:SetDirection(1, -2, 1)
        Add(light)
    end

end

SetApplicationIcon(Libraries.System.File file)

This action sets the program's icon, which appears on the taskbar and on the window frame. This only works on Windows platforms -- otherwise, this action does nothing.

Parameters

Example

use Libraries.Game.Game
use Libraries.System.File

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        File file
        file:SetPath("Icon.png")
        SetApplicationIcon(file)
    end
end

SetCamera2D(Libraries.Game.Graphics.Camera cam)

This action will set the camera that is being used by the current Layer2D.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Graphics.OrthographicCamera

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        OrthographicCamera camera
        SetCamera2D(camera)
    end

end

SetCamera3D(Libraries.Game.Graphics.Camera cam)

This action will set the camera that is being used by the current Layer3D.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Graphics.PerspectiveCamera

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        PerspectiveCamera camera
        SetCamera3D(camera)
    end

end

SetClipboard(text value)

Not all implementations support a clipboard, but all displays support the operations so that they can be called everywhere. If an implementation supports a clipboard, the appopriate system mechanisms are handled automatically. The example here sets a message to the clipboard, which can then be used across other applications.

Parameters

  • text value: this action set text to the system clipboard.

Example

use Libraries.Game.Game

class Main is Game
    action Main
        StartGame()
    end

    action CreateGame
        output SetClipboard("My Message")
    end

    action Update(number seconds)
    end
end

SetColliding(boolean collide)

This allows us to turn collisions on or off for the layer.

Parameters

  • boolean collide

SetColorFilter(Libraries.Game.Graphics.Color color)

Using SetColorFilter will tint all drawn objects on the currently active Layer2D that do not have their own custom color tint. For example, using a red color filter will make all objects drawn on the currently active Layer2D to appear to be more red.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Graphics.Drawable
use Libraries.Game.Graphics.Color

class Main is Game

    Drawable bunny
    Color tint

    action Main
        StartGame()
    end

    action CreateGame
        bunny:Load("Rabbit.png")
        Add(bunny)
        
        tint = tint:Maroon()

        SetColorFilter(tint)
    end
end

SetColorFilter(number red, number green, number blue, number alpha)

SetColorFilter can also be called using four number parameters instead of a color object. The four parameters are the red, green, blue, and opacity of the filter, respectively. All four of the parameters should be between 0 and 1, representing between 0% and 100% of that color component. For example, a value of 0 for red means that the tinting color will have no red, while a value of 1 will have all red components. An opacity of 0 is totally transparent, while an opacity of 1 will be totally visible.

Parameters

  • number red: The red component of the color filter to apply.
  • number green: The green component of the color filter to apply.
  • number blue: The blue component of the color filter to apply.
  • number alpha: The alpha (or transparency) component of the color filter to apply.

Example

use Libraries.Game.Game
use Libraries.Game.Graphics.Drawable

class Main is Game

    Drawable bunny

    action Main
        StartGame()
    end

    action CreateGame
        bunny:Load("Rabbit.png")
        Add(bunny)
        
        // Our color will have 75% red, 0% green, 75% blue, and be
        // totally opaque. This will tint our bunny image purple.

        SetColorFilter(0.75, 0, 0.75, 1)
    end
end

SetConfiguration(Libraries.Game.DesktopConfiguration config)

This action will set the game configuration when run on desktop platforms. The configuration contains data that affect many technical details of the game, such as how large the screen will be. This should be set before calling StartGame().

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.DesktopConfiguration

class Main is Game

    action Main
        DesktopConfiguration configuration
        configuration:width = 1000
        configuration:height = 800
        configuration:resizable = true
        SetConfiguration(configuration)
        StartGame()
    end

end

SetConfiguration(Libraries.Game.WebConfiguration config)

This action will set the game configuration when run on web browsers. The configuration contains data that affect many technical details of the game, such as whether or not to limit the FPS. This should be set before calling StartGame().

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.WebConfiguration

class Main is Game

    action Main
        WebConfiguration configuration
        configuration:containerID = "game-container"
        configuration:capFramesPerSecond = true
        configuration:framesPerSecondLimit = 45
        SetConfiguration(configuration)
        StartGame()
    end

end

SetConfiguration(Libraries.Game.AndroidConfiguration config)

This action will set the game configuration when run on an Android device. The configuration contains data that affect many technical details of the game, such as whether the device should use portrait or landscape orientation while running the game. This should be set before calling StartGame().

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.AndroidConfiguration

class Main is Game

    action Main
        AndroidConfiguration configuration
        configuration:defaultOrientation = configuration:PORTRAIT
        SetConfiguration(configuration)
        StartGame()
    end

end

SetCurrentLayer2D(Libraries.Game.Layer2D layer)

This action will set the currently active Layer2D. The current Layer2D will receive the effect of actions such as Add(Item2D) or Remove(Item2D), which do not specify which Layer to act upon. Other actions that specify an index or a Layer to act upon will ignore this setting.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Layer2D
use Libraries.Game.Graphics.Drawable
use Libraries.Game.Graphics.Color

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color

        Drawable box1
        box1:LoadFilledRectangle(200, 200, color:Maroon())
        box1:SetPosition(250, 150)

        Drawable box2
        box2:LoadFilledRectangle(200, 200, color:Teal())
        box2:SetPosition(350, 250)

        Layer2D layer
        AddLayer(0, layer)

        Add(box1)

        SetCurrentLayer2D(layer)
        Add(box2)
    end

end

SetCurrentLayer3D(Libraries.Game.Layer3D layer)

This action will set the currently active Layer3D. The current Layer3D will receive the effect of actions such as Add(Item3D) or Remove(Item3D), which do not specify which Layer to act upon. Other actions that specify an index or a Layer to act upon will ignore this setting.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Game.Graphics.Model
use Libraries.Game.Graphics.Color

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color

        Model box1
        box1:LoadBox(2, 2, 2, color:Teal())
        box1:SetPosition(0, 0, 5)

        Model box2
        box2:LoadBox(5, 5, 5, color:Maroon())
        box2:SetPosition(0, 0, 2)

        Layer3D layer
        AddLayer(0, layer)

        Add(box1)

        SetCurrentLayer3D(layer)
        Add(box2)
    end

end

SetDefaultInputTable(Libraries.Game.InputTable table)

SetEditManager(Libraries.Interface.Undo.EditManager edits)

This action sets the default EditManager from the system to a custom one.

Parameters

Example

use Libraries.Game.Game
use Libraries.Interface.Undo.EditManager

class Main is Game
    action Main
        StartGame()
    end

    action CreateGame
        EditManager edits
        SetEditManager(edits)
    end

    action Update(number seconds)
    end
end

SetFirstLetterNavigationTime(number firstLetterNavigationTime)

This action finds the first Item2D that has been added to the Game with the given name and returns it. If no Item2D with the given name can be found, this action returns undefined instead.

Parameters

  • number firstLetterNavigationTime

SetFocus(Libraries.Interface.Item item)

This action sets the focus on the given item. This will immediately notify all focus listeners on the previous focus that the Item has lost focus, and all focus listeners on the new focus that the Item has gained focus.

Parameters

SetFocusManager(Libraries.Game.FocusManager focus)

This action sets the FocusManager to be used for the Game. The FocusManager is responsible for moving focus between Items, which is essential for GUIs to function correctly.

Parameters

SetFontManager(Libraries.Game.Graphics.Fonts.FontManager fontManager)

This action sets the FontManager to be used for the Game. The FontManager is responsible for loading and storing font information.

Parameters

SetFullScreen(boolean fullScreen)

This action sets whether the game should launch in full screen or windowed mode on desktop platforms (e.g. Windows or Mac) when the game is started. By default, games are windowed. This action should be called before calling StartGame().

Parameters

  • boolean fullScreen: Whether or not the Game should launch in full screen mode on desktops.

Example

use Libraries.Game.Game

class Main is Game

    number timer = 0

    action Main
        SetFullScreen(true)
        StartGame()
    end

    action CreateGame
    end

    action Update(number seconds)
        timer = timer + seconds
        if timer > 3
            output "Exiting game..."
            Exit()
        end
    end

end

SetGameName(text name)

This action sets the name of the game. The default name is "Game". This action should be called before calling StartGame(). On desktop platforms, this name is displayed at the top of the window. On the web, it is only used for accessibility. This action currently has no effect on other platforms.

Parameters

  • text name: The name to display on the Game window.

Example

use Libraries.Game.Game

class Main is Game

    action Main
        SetGameName("Mariachi Band Simulator 3000")
        StartGame()
    end
end

SetGravity2D(Libraries.Compute.Vector2 gravity)

This action will return an iterator containing all of the PointLight objects stored within the currently active Layer3D.

Parameters

SetGravity2D(number gravityX, number gravityY)

This action will return an iterator containing all of the DirectionalLight objects stored within the currently active Layer3D.

Parameters

  • number gravityX
  • number gravityY

SetGravity3D(Libraries.Compute.Vector3 gravity)

This action will get a PointLight from the currently active Layer3D, which is stored at the given index inside the layer. If there are no PointLights within the layer, or if the index is out of bounds, then an error will be thrown.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Graphics.Model
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.AmbientLight
use Libraries.Game.Graphics.PointLight

class Main is Game

    PointLight myLight

    action Main
        StartGame()
    end

    action CreateGame
        Color color

        Model box
        box:LoadBox(2, 2, 2, color:Teal())
        Add(box)

        AmbientLight ambient
        ambient:SetColor(0.4, 0.4, 0.4, 1)
        SetAmbientLight(ambient)

        PointLight light
        light:SetColor(0.8, 0.8, 0.8, 1)
        light:SetPosition(4, 3, -2)
        light:SetIntensity(30)
        Add(light)

        myLight = GetPointLight(0)
    end

end

SetGravity3D(number gravityX, number gravityY, number gravityZ)

This action will get a DirectionalLight from the currently active Layer3D, which is stored at the given index inside the layer. If there are no DirectionalLights within the layer, or if the index is out of bounds, then an error will be thrown.

Parameters

  • number gravityX
  • number gravityY
  • number gravityZ

Example

use Libraries.Game.Game
use Libraries.Game.Graphics.Model
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.AmbientLight
use Libraries.Game.Graphics.DirectionalLight

class Main is Game

    DirectionalLight myLight

    action Main
        StartGame()
    end

    action CreateGame
        Color color

        Model box
        box:LoadBox(2, 2, 2, color:Teal())
        Add(box)

        AmbientLight ambient
        ambient:SetColor(0.4, 0.4, 0.4, 1)
        SetAmbientLight(ambient)

        DirectionalLight light
        light:SetColor(0.8, 0.8, 0.8, 1)
        light:SetDirection(1, -2, 1)
        Add(light)

        myLight = GetDirectionalLight(0)
    end

end

SetInterfaceOptions(Libraries.Interface.Options.InterfaceOptions options)

This action sets the InterfaceOptions being used by the game, providing default colors and properties for Controls. This affects all Controls currently in the game or that are added later.

Parameters

Example

use Libraries.Game.Game
use Libraries.Interface.Options.DarkModeOptions

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        // DarkModeOptions is one kind of InterfaceOptions we could use for our game.
        // It will use darker colors to draw interface elements, like Buttons, by default.
        DarkModeOptions options
        SetInterfaceOptions(options)
    end
end

SetInterfaceScale(number scale)

The SetInterfaceScale action sets the scale of the user interface. Larger scaling values make each interface component larger. When the interface is scaled in this way, components that can be re-rendered at a higher resolution (such as fonts) will do so.

Parameters

  • number scale: The new interface rendering scale to use.

Example

use Libraries.Game.Game
use Libraries.Interface.Layouts.FlowLayout
use Libraries.Interface.Controls.Button

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        FlowLayout layout
        SetLayout(layout)

        Button button1
        button1:SetName("My Button")
        Add(button1)

        SetInterfaceScale(2.0)
    end
end

SetLayer(integer index, Libraries.Game.Layer layer)

This action will set the given index to use the given Layer, overwriting any Layer that was already at that index. This will not force disposal of any resources that the Layer's items may have been using.

Parameters

  • integer index: The index to set the Layer at.
  • Libraries.Game.Layer: The Layer to be added to the Game. use Libraries.Game.Game use Libraries.Game.Layer2D class Main is Game action Main StartGame() end action CreateGame // This will set the layer at index 0, making it the first layer drawn. Layer2D layer SetLayer(0, layer) end action Update(number seconds) end end

SetLayout(Libraries.Interface.Layouts.Layout layout)

The SetLayout action is used to apply a layout to all Controls on the default Layer2D.

Parameters

Example

use Libraries.Game.Game
use Libraries.Interface.Layouts.FlowLayout
use Libraries.Interface.Controls.Button

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        FlowLayout layout
        SetLayout(layout)

        Button button1
        button1:SetName("My Button")
        Add(button1)
    end
end

SetPenColor(number red, number green, number blue, number alpha)

Parameters

  • number red
  • number green
  • number blue
  • number alpha

SetPenColor(text color)

Parameters

  • text color

SetPenWidth(integer width)

Parameters

  • integer width

SetSceneManager(Libraries.Game.Scenes.SceneManager scene)

This action sets the manager used to save and load scenes in the Game.

Parameters

SetScreenResolution(Libraries.Game.ScreenResolution resolution, boolean adjustCameras)

This action will set a game running on a desktop platform to use the given ScreenResolution. This will have no effect on non-desktop platforms. If the second parameter is set to true, then this action will also adjust the size of the cameras on the default 2D and 3D layers to match the new screen size. If the parameter is false, then the cameras will not be changed.

Parameters

  • Libraries.Game.ScreenResolution: The ScreenResolution to use for the game's display.
  • boolean adjustCameras: True to adjust the default cameras to the new dimensions, false to keep the cameras the same.

Example

use Libraries.Game.Game
use Libraries.Game.ScreenResolution
use Libraries.Game.InputMonitor
use Libraries.Interface.Events.KeyboardEvent
use Libraries.Game.Graphics.Drawable

class Main is Game

    InputMonitor monitor
    KeyboardEvent keys

    action Main
        StartGame()
    end

    action CreateGame
        Drawable leftSquare
        leftSquare:LoadFilledRectangle(100, 100)
        leftSquare:SetPosition(0, 250)
        Add(leftSquare)

        Drawable rightSquare
        rightSquare:LoadFilledRectangle(100, 100)
        rightSquare:SetPosition(700, 250)
        Add(rightSquare)
    end

    action Update(number seconds)
        // Pressing the spacebar will set the game to use the desktop's resolution.
        // If the boolean is false, the cameras will not be adjusted to the new screen size,
        // making them appear to be zoomed in on the original area.
        // If the boolean is true (or omitted), the cameras will be adjusted to view the
        // new size of the screen. Drawables will remain at their original size and position.
        if monitor:IsKeyPressed(keys:SPACE)
            ScreenResolution resolution = GetDesktopResolution()
            SetScreenResolution(resolution, false)
        end
        // Using the desktop resolution will typically make the game go fullscreen.
        // To exit the game, the user can press the ESCAPE key.
        if monitor:IsKeyPressed(keys:ESCAPE)
            Exit()
        end
    end
end

SetScreenResolution(Libraries.Game.ScreenResolution resolution)

This action will set a game running on a desktop platform to use the given ScreenResolution. This will have no effect on non-desktop platforms. Using this action will also adjust the size of the cameras on the default 2D and 3D layers to match the new screen size. To change the screen size without changing the cameras, use SetScreenResolution(ScreenResolution, false).

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.ScreenResolution
use Libraries.Game.InputMonitor
use Libraries.Interface.Events.KeyboardEvent

class Main is Game

    InputMonitor monitor
    KeyboardEvent keys

    action Main
        StartGame()
    end

    action CreateGame
        ScreenResolution resolution = GetDesktopResolution()
        SetScreenResolution(resolution)
    end

    action Update(number seconds)
        // Using the desktop resolution will typically make the game go fullscreen.
        // To exit the game, the user can press the ESCAPE key.
        if monitor:IsKeyPressed(keys:ESCAPE)
            Exit()
        end
    end
end

SetScreenSize(integer width, integer height, boolean adjustCameras)

This action sets windowed size of the game (the default size is 800 by 600). This action can be called before calling StartGame() to set the initial window size. If this action is used when the game is in fullscreen, it will return it to windowed mode. If the game is already running and the boolean parameter is set to true, then the default cameras will be adjusted to fit the new window size. If the value is set to false, the cameras will not be adjusted.

Parameters

  • integer width: The screen width.
  • integer height: The screen height.
  • boolean adjustCameras: True to adjust the default cameras to the new dimensions, false to keep the cameras the same.

Example

use Libraries.Game.Game

class Main is Game

    action Main
        SetScreenSize(1024, 800)
        StartGame()
    end
end

SetScreenSize(integer width, integer height)

This action sets windowed size of the game (the default size is 800 by 600). This action can be called before calling StartGame() to set the initial window size. If this action is used when the game is in fullscreen, it will return it to windowed mode. If the game is already started, this action will adjust the cameras on the default 2D and 3D layers to correspond to the new window size.

Parameters

  • integer width: The screen width.
  • integer height: The screen height.

Example

use Libraries.Game.Game

class Main is Game

    action Main
        SetScreenSize(1024, 800)
        StartGame()
    end
end

SetSimulationThreshold2D(number threshold)

The GetSkybox action will return the Skybox in use by the currently active Layer3D. By default, a Layer3D does not start with a Skybox, so using this on a Layer3D that hasn't had a Skybox assigned to it will return undefined.

Parameters

  • number threshold

Example

use Libraries.Game.Game
use Libraries.Game.Graphics.Skybox

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Skybox skybox
        // Assuming we have a folder named "skybox" containing our six images.
        skybox:Load("skybox/right.jpg", "skybox/left.jpg", "skybox/top.jpg", "skybox/bottom.jpg", "skybox/front.jpg", "skybox/back.jpg")
        SetSkybox(skybox)

        // We can get the Skybox back from the layer using GetSkybox().
        Skybox currentSkybox = GetSkybox()
    end

end

SetSkybox(Libraries.Game.Graphics.Skybox skybox)

The SetSkybox action will set the currently active Layer3D to use the given Skybox.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Graphics.Skybox

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Skybox skybox
        // Assuming we have a folder named "skybox" containing our six images.
        skybox:Load("skybox/right.jpg", "skybox/left.jpg", "skybox/top.jpg", "skybox/bottom.jpg", "skybox/front.jpg", "skybox/back.jpg")
        SetSkybox(skybox)
    end

end

SetStartingCoordinates(integer x, integer y)

Parameters

  • integer x
  • integer y

SetVSync(boolean vSync)

This action enables or disables vSync in the game. Passing a value of true enables it, a value of false disables it. vSync is enabled by default. This action should be called before calling StartGame(). This option is only used when the game is run on desktops.

Parameters

  • boolean vSync: Whether or not vSync should be enabled.

Example

use Libraries.Game.Game

class Main is Game

    action Main
        SetVSync(false)
        StartGame()
    end
end

SetWebContainerID(text id)

The SetWebContainerID action determines which container to use on a webpage. When the game runs, it will be displayed in the designated container. If no container ID is given, the engine will attempt to find a container with the default ID, "QuorumUIContainer". If the engine can't find a container with the set ID, it will not run. This action has no effect if called inside a game that isn't being run online.

Parameters

  • text id: The ID of the canvas to display the game in.

Example

use Libraries.Game.Game
use Libraries.Game.WebConfiguration

class Main is Game

    action Main
        SetWebContainerID("myContainer")
        StartGame()
    end
end

SetWindowMaximized(boolean maximized)

This action maximizes the screen, or restores a maximized screen to its original size. If this is called before the Game window opens, it will launch the window in maximized mode. If the Game is being displayed in full screen, this action will do nothing. This action is only for desktop platforms -- on other platforms, it does nothing.

Parameters

  • boolean maximized: True to maximize the window, or false to restore it to its original size.

Example

use Libraries.Game.Game

class Main is Game

    action Main
        SetWindowMaximized(true)
        StartGame()
    end
end

SetWindowMinimized(boolean minimized)

This action minimizes the screen, or restores a minimized screen to its original size. This action is only for desktop platforms -- on other platforms, it does nothing.

Parameters

  • boolean minimized: True to minimize the window, or false to restore it to its original size.

Example

use Libraries.Game.Game

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        SetWindowMinimized(true)
    end
end

StartGame()

The StartGame action will start your game. Specifically, it does this: 1. Creates the Game window. 2. Calls the CreateGame() action. 3. Repeatedly calls Update() until Exit() is called or the window is closed. If you are using any actions to change the starting settings of the window, call those before calling StartGame().

Example

use Libraries.Game.Game

class Main
    action Main
        Game game
        Game:StartGame()
    end
end

TurnLeft()

TurnRight()

TurtleCommands()

Update(number time)

The Update action is where most of the game's logic goes. The code inside Update will be called on every frame of the game. In other words, for every time a picture is drawn on the screen, the Update action is called. The number parameter is the amount of seconds that has passed since the last time Update was called.

Parameters

  • number time: The number of seconds that have passed since the last time Update was called.

Example

use Libraries.Game.Game

class Main is Game

    action Main
        StartGame()
    end

    // It is very important when making our own Update action that it has
    // the time parameter! If we don't have it, it won't be called.
    action Update(number time)
        output "Update was called!"
    end
end

UseDesktopResolution(boolean adjustCameras)

UseDesktopResolution will set the game to use the same display settings as the desktop's current screen resolution (independent of the game). This is only effective when used on desktop platforms - on other platforms, this will do nothing. If the boolean parameter is set to true, then this action will also adjust the size of the cameras on the default 2D and 3D layers to match the new screen size. If the parameter is false, then the cameras will not be changed.

Parameters

  • boolean adjustCameras: True to adjust the default cameras to the new dimensions, false to keep the cameras the same.

Example

use Libraries.Game.Game
use Libraries.Game.InputMonitor
use Libraries.Interface.Events.KeyboardEvent
use Libraries.Game.Graphics.Drawable

class Main is Game

    InputMonitor monitor
    KeyboardEvent keys

    action Main
        StartGame()
    end

    action CreateGame
        Drawable leftSquare
        leftSquare:LoadFilledRectangle(100, 100)
        leftSquare:SetPosition(0, 250)
        Add(leftSquare)

        Drawable rightSquare
        rightSquare:LoadFilledRectangle(100, 100)
        rightSquare:SetPosition(700, 250)
        Add(rightSquare)
    end

    action Update(number seconds)
        // Pressing the spacebar will set the game to use the desktop's resolution.
        // If the boolean is false, the cameras will not be adjusted to the new screen size,
        // making them appear to be zoomed in on the original area.
        // If the boolean is true (or omitted), the cameras will be adjusted to view the
        // new size of the screen. Drawables will remain at their original size and position.
        if monitor:IsKeyPressed(keys:SPACE)
            UseDesktopResolution(false)
        end
        // Using the desktop resolution will typically make the game go fullscreen.
        // To exit the game, the user can press the ESCAPE key.
        if monitor:IsKeyPressed(keys:ESCAPE)
            Exit()
        end
    end
end

UseDesktopResolution()

UseDesktopResolution will set the game to use the same display settings as the desktop's current screen resolution (independent of the game). This is only effective when used on desktop platforms - on other platforms, this will do nothing. Using this action will also adjust the size of the cameras on the default 2D and 3D layers to match the new screen size. To change the screen size without changing the cameras, use SetScreenResolution(ScreenResolution, false).

Example

use Libraries.Game.Game
use Libraries.Game.InputMonitor
use Libraries.Interface.Events.KeyboardEvent

class Main is Game

    InputMonitor monitor
    KeyboardEvent keys

    action Main
        StartGame()
    end

    action CreateGame
        UseDesktopResolution()
    end

    action Update(number seconds)
        // Using the desktop resolution will typically make the game go fullscreen.
        // To exit the game, the user can press the ESCAPE key.
        if monitor:IsKeyPressed(keys:ESCAPE)
            Exit()
        end
    end
end