BGE


Static Methods

nextDrawMode( current: BGE.SceneObjectDrawMode, first?: BGE.SceneObjectDrawMode, last?: BGE.SceneObjectDrawMode, ): BGE.SceneObjectDrawMode

static

The draw mode after current, wrapping from last back to first. A mode outside the range goes to first.

Parameters

Returns

setEntityDrawMode( entity: BGE.GameEntity, drawMode: BGE.SceneObjectDrawMode, ): void

static

Puts every drawable on an entity into one draw mode.

Parameters

Returns

  • void

cycleDrawMode( entity: BGE.GameEntity, first?: BGE.SceneObjectDrawMode, last?: BGE.SceneObjectDrawMode, ): BGE.SceneObjectDrawMode

static

Moves every drawable on an entity to the draw mode after its first drawable's (see nextDrawMode()), so they all end up in the same mode. For demos that step through the draw modes on a button press.

Parameters

Returns

separateCircles( bodies: Array.<BGE.CircleBody>, plane?: BGE.SeparationPlane, ): integer

static

Pushes overlapping circular bodies apart, so characters can't walk through each other. Each overlap is split by mass: the lighter body moves further. Call it once per frame after everything has moved, e.g. from GameScene.onPostUpdate(), so the result doesn't depend on entity update order. Pairwise, so it suits tens of bodies, not crowds of hundreds.

Parameters

Returns

  • integer — how many overlapping pairs were pushed apart

sphereOverlap( centerA: BGE.Math.Vector, radiusA: float, centerB: BGE.Math.Vector, radiusB: float, ): BGE.Sphere3dCollisionResult

static

True 3D sphere-sphere overlap test - the narrow-phase check after the two-plane broad-phase gate, since two spheres can pass both plane checks while never actually touching in 3D (a diagonal near-miss - see the design doc's spike findings).

Parameters

  • centerA (BGE.Math.Vector)
  • radiusA (float)
  • centerB (BGE.Math.Vector)
  • radiusB (float)

Returns

aabbOverlap( minA: BGE.Math.Vector, maxA: BGE.Math.Vector, minB: BGE.Math.Vector, maxB: BGE.Math.Vector, ): BGE.Box3dCollisionResult

static

True 3D AABB-vs-AABB overlap test. Unlike sphereOverlap(), the two-plane broad-phase gate has no false-positive case for boxes (AABB overlap decomposes exactly per axis) - this only computes the penetration/normal result.

Parameters

  • minA (BGE.Math.Vector)
  • maxA (BGE.Math.Vector)
  • minB (BGE.Math.Vector)
  • maxB (BGE.Math.Vector)

Returns

sphereBoxOverlap( sphereCenter: BGE.Math.Vector, radius: float, boxMin: BGE.Math.Vector, boxMax: BGE.Math.Vector, ): BGE.Sphere3dCollisionResult

static

True 3D sphere-vs-AABB overlap test - the only cross-shape pair this engine's 3D collision system supports.

Parameters

  • sphereCenter (BGE.Math.Vector)
  • radius (float)
  • boxMin (BGE.Math.Vector)
  • boxMax (BGE.Math.Vector)

Returns

orientedBoxOverlap( centerA: BGE.Math.Vector, halfA: BGE.Math.Vector, yawA: float, centerB: BGE.Math.Vector, halfB: BGE.Math.Vector, yawB: float, ): BGE.Box3dCollisionResult

static

Box-vs-box overlap where each box may be turned about the y axis through its centre (BoxCollider3d.yaw): a separating-axis test on the boxes' four x/z face axes plus y.

Parameters

  • centerA (BGE.Math.Vector)
  • halfA (BGE.Math.Vector) — half width, height, depth
  • yawA (float) — radians
  • centerB (BGE.Math.Vector)
  • halfB (BGE.Math.Vector)
  • yawB (float)

Returns

sphereOrientedBoxOverlap( sphereCenter: BGE.Math.Vector, radius: float, boxCenter: BGE.Math.Vector, half: BGE.Math.Vector, yaw: float, ): BGE.Sphere3dCollisionResult

static

Sphere-vs-box overlap where the box is turned about the y axis through its centre (BoxCollider3d.yaw): sphereBoxOverlap() in the box's own frame.

Parameters

  • sphereCenter (BGE.Math.Vector)
  • radius (float)
  • boxCenter (BGE.Math.Vector)
  • half (BGE.Math.Vector) — half width, height, depth
  • yaw (float) — radians

Returns

intersectRaySphere( origin: BGE.Math.Vector, direction: BGE.Math.Vector, maxDistance: float, center: BGE.Math.Vector, radius: float, ): BGE.RaycastHit

static

Ray-vs-sphere intersection (the true 3D case; intersectRayCircle() is the 2D specialization below). Returns the nearest intersection point along the ray within [0, maxDistance], or invalid if the ray misses, points away from the sphere, or the sphere is entirely beyond maxDistance. direction must already be a unit vector - the returned distance is only meaningful in the same units as direction's magnitude. If origin is already inside the sphere, returns a hit at distance: 0/point: origin (an arbitrary normal, since there's no entry face) rather than invalid or the far exit point - same convention as intersectRayAabb3d().

Parameters

  • origin (BGE.Math.Vector)
  • direction (BGE.Math.Vector) — must be a unit vector
  • maxDistance (float)
  • center (BGE.Math.Vector)
  • radius (float)

Returns

intersectRayCircle( origin: BGE.Math.Vector, direction: BGE.Math.Vector, maxDistance: float, center: BGE.Math.Vector, radius: float, ): BGE.RaycastHit

static

Ray-vs-circle intersection in the XY plane - z is ignored entirely on both the ray and the circle, by flattening both to z=0 and delegating to intersectRaySphere().

intersectRaySphere()'s math assumes a unit-length direction. Simply zeroing out z (as this used to do) leaves the flattened direction shorter than 1 whenever the original direction had a nonzero z component, silently breaking that assumption. So this renormalizes the flattened direction and rescales maxDistance/distance to compensate: letting len = the flattened direction's own length, a step of t along the original unit direction covers t * len of flat (XY-only) distance, so the flat search runs out to maxDistance * len and the flat hit's distance is converted back with / len.

Parameters

  • origin (BGE.Math.Vector)
  • direction (BGE.Math.Vector) — must be a unit vector
  • maxDistance (float)
  • center (BGE.Math.Vector)
  • radius (float)

Returns

intersectRayAabb3d( origin: BGE.Math.Vector, direction: BGE.Math.Vector, maxDistance: float, minPoint: BGE.Math.Vector, maxPoint: BGE.Math.Vector, ): BGE.RaycastHit

static

Ray-vs-axis-aligned-box intersection via the classic slab method (Kay/Kajiya): each axis narrows [tMin, tMax] to the interval where the ray is within that axis' [lo, hi] slab; if the interval ever becomes empty, the ray misses. The entry face's outward normal is tracked as whichever axis last raised tMin.

Parameters

  • origin (BGE.Math.Vector)
  • direction (BGE.Math.Vector) — must be a unit vector
  • maxDistance (float)
  • minPoint (BGE.Math.Vector)
  • maxPoint (BGE.Math.Vector)

Returns

intersectRayAabb2d( origin: BGE.Math.Vector, direction: BGE.Math.Vector, maxDistance: float, minPoint: BGE.Math.Vector, maxPoint: BGE.Math.Vector, ): BGE.RaycastHit

static

Ray-vs-axis-aligned-rectangle intersection in the XY plane - z is ignored entirely, by flattening the ray to z=0 and widening the box's z-range so the z-axis slab test in intersectRayAabb3d() never constrains the result.

See intersectRayCircle()'s doc comment for why the flattened direction must be renormalized (and maxDistance/distance rescaled to compensate) rather than just zeroing z - the same reasoning applies here.

Parameters

  • origin (BGE.Math.Vector)
  • direction (BGE.Math.Vector) — must be a unit vector
  • maxDistance (float)
  • minPoint (BGE.Math.Vector)
  • maxPoint (BGE.Math.Vector)

Returns

resolveAabbTileCollision( positionBefore: BGE.Math.Vector, currentPosition: BGE.Math.Vector, width: float, height: float, velocity: BGE.Math.Vector, tileCollider: BGE.RectangleCollider, isOneWay?: boolean, tolerancePx?: float, ): BGE.TileCollisionResult

static

Resolves an entity's axis-aligned hitbox against one static rectangular tile collider, using the entity's pre-move position to determine which side it approached from - the generic "solid tile world" resolution algorithm (landing on top, one-way-platform pass-through, head bumps, side pushes) needed by a tile-based platformer or top-down game's GameEntity.onCollision(). It does not replace BGE.Collider/CheckMultipleCollisions() for entity-vs-entity collision - use it only for collisions against static tile geometry.

A resolved position leaves the entity exactly flush against the tile, touching but not overlapping it, so onCollision() won't fire for that tile again next frame unless the entity moves back into it (e.g. under gravity). See GameEntity.onCollision().

The entity's own hitbox is assumed feet-anchored, matching GameEntity.addRectangleCollider()'s own convention: positionBefore is the bottom- center point (x = horizontal center, y = bottom edge), so the hitbox spans positionBefore.x -+ width/2 horizontally and positionBefore.y to positionBefore.y + height vertically.

Precondition: only call this when the entity's current (post-move) position is already known to overlap this tile - e.g. from inside onCollision(), which only fires on a genuine overlap. This function has no independent way to verify an overlap actually exists (it trusts positionBefore/currentPosition/velocity at face value); called with values that were never actually approaching/touching, its returned side is not meaningful (this mirrors the exact same precondition the hand-rolled onCollision() logic it replaces already had, implicitly, by virtue of only ever running inside onCollision()).

Parameters

  • positionBefore (BGE.Math.Vector) — the entity's position as of the start of this frame, before this frame's own movement was applied (capture it at the top of onUpdate(), before integrating velocity) - used to tell which side of the tile the entity approached from.
  • currentPosition (BGE.Math.Vector) — the entity's actual position right now (at the moment onCollision() fires) - this is what gets returned unchanged on the axis that isn't resolved this call, and as the base every resolved axis's correction is applied on top of. Do NOT pass positionBefore here - by the time onCollision() runs, the engine has already integrated this frame's velocity into the entity's position (see Game.bs's processEntitiesPreDraw -> processEntitiesCollisions ordering), so currentPosition and positionBefore are genuinely different values whenever the entity moved at all this frame.
  • width (float) — the entity's hitbox width (matching the width passed to addRectangleCollider())
  • height (float) — the entity's hitbox height
  • velocity (BGE.Math.Vector) — the entity's current velocity (only .y's sign matters for landing/head-bump detection)
  • tileCollider (BGE.RectangleCollider) — the tile's own collider (the otherCollider passed to onCollision()), whose offset is the tile's top-left corner in world space, e.g. addRectangleCollider(tileName, TileSize, TileSize, leftX, topY)
  • isOneWay (boolean, optional, default: false) — true if this tile only blocks a from-above landing and passes through from below/the sides (e.g. a one-way platform)
  • tolerancePx (float, optional, default: "1.0") — how many pixels of overlap/gap still count as "touching" a side, absorbing floating-point/frame-step slack

Returns

newFullHeightParallaxLayer( owner: BGE.GameEntity, region: roRegion, canvasWidth: float, canvasHeight: float, factor: float, targetX?: float, targetY?: float, zOffset?: float, ): BGE.DrawableParallaxLayer

static

Builds a DrawableParallaxLayer scaled to fill the canvas vertically edge-to-edge and tiled to cover it on both axes, with its tile-repeat seam anchored at a chosen canvas position (targetX, targetY) rather than wherever computeEffectiveWorldPosition()'s own reference-position capture would otherwise put it - see that method's own derivation comment, and examples/platformer's MainScene for a worked application (including staggering several stacked layers' seams via different targetX values so they don't all reinforce into one obvious seam).

This assumes owner sits at world (0,0,0) and the camera's target on the axis orthogonal to factor's own drift direction stays fixed for the object's lifetime (e.g. a side-scroller with a Y-locked camera) - it is not a general-purpose "anchor anywhere under any camera motion" solution. See examples/parallax's own hand-rolled newLayer() for a different derivation (owner co-located with a moving camera target, non-uniform per-axis factor) that this helper does not cover.

Note: this function deliberately lives in its own file, separate from DrawableParallaxLayer.bs - a namespace-level free function whose return type self-references a class defined in the SAME file triggers a real BrighterScript compiler bug (confirmed via bisection: a trivial return invalid body with the same signature still fails, and changing only the return type to as object "fixes" it - the trigger is the self-referential return type, not this function's body). Keeping it in a separate file (importing DrawableParallaxLayer.bs) avoids the bug entirely while keeping full type fidelity on the return type.

Parameters

  • owner (BGE.GameEntity) — the entity this layer attaches to; must sit at world (0,0,0)
  • region (roRegion) — the bitmap tile to scroll/repeat
  • canvasWidth (float)
  • canvasHeight (float)
  • factor (float) — parallaxFactor applied uniformly to both axes - must be nonzero; a fully camera-pinned layer (factor = 0) is not supported by this helper's offset math (it would divide by zero).
  • targetX (float, optional, default: "0.0") — on-canvas X the tile seam lands at while the camera sits at canvasWidth/2 (its assumed rest position on this axis)
  • targetY (float, optional, default: "0.0") — on-canvas Y the tile seam lands at, given the camera's fixed Y target (canvasHeight/2 is the common "camera always centers vertically" case)
  • zOffset (float, optional, default: "0.0") — Z offset for this layer, useful for stacking several layers' draw order via BGE.DrawableParallaxLayer's normal Z-based sort

Returns

frameRateFor( frameCount: integer, seconds: float, minFrameRate?: float, ): float

static

The frame rate that plays frameCount frames over exactly seconds, e.g. a 3-frame attack windup that has to last 1.1s. With minFrameRate, never slower than that: a long one-shot (SpritePlayMode.Forward) animation then finishes early and holds its last frame, rather than stepping through its frames slowly.

Parameters

  • frameCount (integer)
  • seconds (float)
  • minFrameRate (float, optional, default: "0.0") — frames per second it never drops below (0: none)

Returns

  • float — frames per second, or 0 (which addAnimation rejects) if seconds isn't above 0

frameRateForStride( frameCount: integer, stride: float, speed: float, ): float

static

The frame rate for a walk or run cycle that covers stride distance per loop, so the feet don't slide at speed. E.g. an 8-frame run cycle that covers 3.3 m: BGE.frameRateForStride(8, 3.3, speed).

Parameters

  • frameCount (integer) — frames in one cycle
  • stride (float) — distance one cycle covers
  • speed (float) — distance per second

Returns

  • float — frames per second, or 0 (which addAnimation rejects) if stride or speed isn't above 0

resizeBitmap( bitmap: roBitmap, width: integer, height: integer, smooth?: boolean, ): roBitmap

static

A copy of a bitmap at a new size, for when the texture manager can't do the resize.

Parameters

  • bitmap (roBitmap)
  • width (integer)
  • height (integer)
  • smooth (boolean, optional, default: true) — false scales with nearest neighbour

Returns

  • roBitmap — invalid if the new bitmap couldn't be made (e.g. out of texture memory)

getTiledMapBitmapName( mapName: string, imagePath: string, ): string

static

The game bitmap name AssetLoader.loadTiledMap() stores a map's image under.

Parameters

  • mapName (string)
  • imagePath (string) — the image's resolved path or URL

Returns

  • string

getRenderQualityModelPrefix(model: string): string

static

The model-code prefix used to look a device up: everything up to the first "X" after the leading 3-4 characters (e.g. "3941X2" -> "3941", "C000GB" -> "C000", "K8PXX" -> "K8P"), or the first four characters when there is no "X".

Parameters

  • model (string) — roDeviceInfo.GetModel()

Returns

  • string

seedRenderQualityLevel( model: string, graphicsPlatform: string, uiResolutionName: string, isSimulator: boolean, ): RenderQualityLevel

static

Starting quality level for a device. Pure - seedRenderQualityLevelForDevice() calls this with the real device's values.

Parameters

  • model (string) — roDeviceInfo.GetModel(), e.g. "4850X"
  • graphicsPlatform (string) — roDeviceInfo.GetGraphicsPlatform(), "opengl" or "directfb"
  • uiResolutionName (string) — roDeviceInfo.GetUIResolution().name: "SD", "HD" or "FHD"
  • isSimulator (boolean) — whether this is the BrightScript simulator

Returns

seedRenderQualityLevelForDevice(): RenderQualityLevel

static

Reads this device's model, graphics platform and resolution and returns its starting quality level. Game calls this for you.

Returns

getRenderQualityModelTable(): roAssociativeArray

static

Known model prefixes -> level, from developer.roku.com/dev/docs/hardware ("Current" and "Updatable" models). Add or correct entries as real benchmark data comes in.

Returns

  • roAssociativeArray

lookUpRenderQualityModel(prefix: string): integer

static

Table lookup with inference for unknown codes; -1 when nothing fits.

Parameters

  • prefix (string)

Returns

  • integer

isRenderQualityNumericCode(code: string): boolean

static

"4850", "3941": four digits

Parameters

  • code (string)

Returns

  • boolean

isRenderQualityTvCode(code: string): boolean

static

"M000", "K8P": a letter followed by a digit

Parameters

  • code (string)

Returns

  • boolean

getRenderQualityLevelName(level: integer): string

static

Display name for a quality level, e.g. "High".

Parameters

  • level (integer) — a BGE.RenderQualityLevel value

Returns

  • string

clampRenderQualityLevel(level: integer): RenderQualityLevel

static

Clamps any integer into the valid BGE.RenderQualityLevel range.

Parameters

  • level (integer)

Returns

getRenderQualityPreset(level: integer): RenderQualitySettings

static

The engine's built-in settings for a quality level, as a new copy each call.

Parameters

  • level (integer) — a BGE.RenderQualityLevel value (clamped)

Returns

mergeRenderQualitySettings( base: BGE.RenderQualitySettings, overrides: BGE.RenderQualitySettingsOverrides, ): RenderQualitySettings

static

Copies base, replacing each field named in overrides. Keys that aren't quality settings are ignored.

Parameters

Returns

newSceneObjectId(): string

static

A scene object id no other renderer has handed out. Shared across renderers, since one Drawable registered with two renderers keys its scene objects by id (issue #343).

Returns

  • string

getNewMemoryScratchRegion( width: float, height: float, ): ScratchRegion

static

Parameters

  • width (float)
  • height (float)

Returns

QuadColumnNearZ(focal: float): float

static

The camera-space z a quad drawn as columns is clipped at, for a perspective projection with this focal length: nothing clipped there projects more than ~64x off center, since huge columns aren't drawn reliably.

Parameters

  • focal (float) — focal length in pixels

Returns

  • float

getPlanePrePerspectiveMaxPixels(): float

static

This device's pixel budget for a ground plane's top-down bitmap - each plane has its own, and at the full budget two planes take a quarter of an HD-tier Roku's 64MB of texture memory (#151).

Returns

  • float

getPlanePrePerspectiveBmpSize( farDistance: float, fovDegrees: float, maxPixels: float, ): SizeWH

static

Size of a ground plane's top-down bitmap: a wedge farDistance deep and 2 * farDistance * tan(fov / 2) wide at 1 pixel per world unit, scaled down uniformly if that would exceed maxPixels.

Parameters

  • farDistance (float) — how far the plane draws, in world units
  • fovDegrees (float) — the camera's horizontal field of view
  • maxPixels (float) — pixel budget

Returns

isBackFaceDrawMode(drawMode: SceneObjectDrawMode): boolean

static

Parameters

Returns

  • boolean

isDirectDrawMode(drawMode: SceneObjectDrawMode): boolean

static

Parameters

Returns

  • boolean

isOrientedDrawMode(drawMode: SceneObjectDrawMode): boolean

static

Parameters

Returns

  • boolean

isScreenAlignedDrawMode(drawMode: SceneObjectDrawMode): boolean

static

The draw modes that keep an object square to the screen rather than turning it in 3D - the billboard modes. directScaled belongs here even though isOrientedDrawMode groups it with the oriented modes: it faces the camera like directToCamera and only differs in taking its size from how far away it is (a Doom-style sprite).

Parameters

Returns

  • boolean

isCameraFacingQuadDrawMode( drawMode: SceneObjectDrawMode, ): boolean

static

The billboard modes that build a quad facing the camera in world space and project it, so they shrink with distance: directScaled, and axisAligned, which keeps the quad upright.

Parameters

Returns

  • boolean

isWireFrameDrawMode(drawMode: SceneObjectDrawMode): boolean

static

Parameters

Returns

  • boolean

isSolidDrawMode(drawMode: SceneObjectDrawMode): boolean

static

Parameters

Returns

  • boolean

isFullDrawMode(drawMode: SceneObjectDrawMode): boolean

static

Parameters

Returns

  • boolean

getDrawModeName(drawMode: SceneObjectDrawMode): string

static

The name of a draw mode, as written in the SceneObjectDrawMode enum - handy for debug overlays and for examples that let you cycle through the draw modes.

Parameters

Returns

  • string — the mode's name, or "unknown" for a value outside the enum

getDrawModeBooleanLookupArray( defaultValue?: boolean, ): Array.<boolean>

static

Parameters

  • defaultValue (boolean, optional, default: false)

Returns

  • Array.<boolean>

getDotProductFromSurfaceToCamera( rendererObj: BGE.Renderer, facePoint: BGE.Math.Vector, faceNormal: BGE.Math.Vector, ): float

static

Parameters

  • rendererObj (BGE.Renderer)
  • facePoint (BGE.Math.Vector)
  • faceNormal (BGE.Math.Vector)

Returns

  • float

isNormalFacingCamera( rendererObj: BGE.Renderer, facePoint: BGE.Math.Vector, faceNormal: BGE.Math.Vector, ): boolean

static

Parameters

  • rendererObj (BGE.Renderer)
  • facePoint (BGE.Math.Vector)
  • faceNormal (BGE.Math.Vector)

Returns

  • boolean

isOutwardNormalFacingCamera( rendererObj: BGE.Renderer, facePoint: BGE.Math.Vector, faceNormal: BGE.Math.Vector, ): boolean

static

Model faces carry outward normals (counter-clockwise winding seen from outside, the .obj/.stl convention), so a face is front-facing when its normal points back toward the camera.

Parameters

  • rendererObj (BGE.Renderer)
  • facePoint (BGE.Math.Vector)
  • faceNormal (BGE.Math.Vector)

Returns

  • boolean

getOutwardNormalFacingAmount( rendererObj: BGE.Renderer, facePoint: BGE.Math.Vector, faceNormal: BGE.Math.Vector, ): float

static

How directly an outward normal faces the camera: 1 head on, 0 or less edge-on or away.

Parameters

  • rendererObj (BGE.Renderer)
  • facePoint (BGE.Math.Vector)
  • faceNormal (BGE.Math.Vector)

Returns

  • float

createWallSegment( startPoint: BGE.Math.Vector, endPoint: BGE.Math.Vector, bottom: float, top: float, texture: string, options?: BGE.WallSegmentOptions, ): BGE.WallSegment

static

A wall from startPoint to endPoint on the floor (x and z), from height bottom to top. One-sided walls face the left of start -> end seen from above, with -z forward (a wall from x=0 to x=1 at z=0 faces -z), so list a room's walls clockwise to face inwards.

Parameters

  • startPoint (BGE.Math.Vector)
  • endPoint (BGE.Math.Vector)
  • bottom (float)
  • top (float)
  • texture (string) — texture name
  • options (BGE.WallSegmentOptions, optional, default: "{}")

Returns

isIntegerString(text: string): boolean

static

Is text a whole number, e.g. "42", " -3 "?

Parameters

  • text (string)

Returns

  • boolean

isNumberString(text: string): boolean

static

Is text a number, e.g. "4", "-0.5", "1e3"?

Parameters

  • text (string)

Returns

  • boolean

integerStringPattern(): roRegex

static

Matches a whole number - see isIntegerString().

Returns

  • roRegex

numberStringPattern(): roRegex

static

Matches a number - see isNumberString().

Returns

  • roRegex

fitsInInteger(text: string): boolean

static

Does a whole number string (see isIntegerString(), trimmed) fit in a 32-bit integer?

Parameters

  • text (string)

Returns

  • boolean

isIntegerValue(value: dynamic): boolean

static

Is this an integer, boxed or not?

Parameters

  • value (dynamic)

Returns

  • boolean

HSVtoRGBA( hPercent: float, sPercent: float, vPercent: float, a?: integer, ): integer

static

Parameters

  • hPercent (float)
  • sPercent (float)
  • vPercent (float)
  • a (integer, optional, default: -1)

Returns

  • integer

RGBAtoRGBA( red: integer, green: integer, blue: integer, alpha?: float, ): integer

static

Parameters

  • red (integer)
  • green (integer)
  • blue (integer)
  • alpha (float, optional, default: 1)

Returns

  • integer

unpackRGB(rgb: integer): roAssociativeArray

static

Unpacks a packed RGB color (0xRRGGBB) into its R/G/B channels.

Parameters

  • rgb (integer)

Returns

  • roAssociativeArray — {r, g, b}, each 0-255

unpackRGBA(rgba: integer): roAssociativeArray

static

Unpacks a packed RGBA color (0xRRGGBBAA) into its R/G/B/A channels.

Parameters

  • rgba (integer)

Returns

  • roAssociativeArray — {r, g, b, a}, each 0-255

GetColor(name: string): integer

static

Looks up a BGE.Colors value by CSS color name (case-insensitive). Falls back to White for a name that isn't a known color.

Parameters

  • name (string)

Returns

  • integer

GetColorRGB(name: string): integer

static

Looks up a BGE.ColorsRGB value by CSS color name (case-insensitive). Falls back to White for a name that isn't a known color.

Parameters

  • name (string)

Returns

  • integer

getRandomColorRGB( r?: integer, g?: integer, b?: integer, ): integer

static

A random color as a packed RGB integer (0xRRGGBB, no alpha byte) - the format Drawable.color/Drawable.outlineRGBA expect. Use getRandomColorRGBA for the packed-RGBA format the Renderer.draw* calls take.

Parameters

  • r (integer, optional, default: 255) — exclusive upper bound for the red channel
  • g (integer, optional, default: 255) — exclusive upper bound for the green channel
  • b (integer, optional, default: 255) — exclusive upper bound for the blue channel

Returns

  • integer — packed RGB color

getRandomColorRGBA( r?: integer, g?: integer, b?: integer, a?: integer, ): integer

static

Parameters

  • r (integer, optional, default: 255)
  • g (integer, optional, default: 255)
  • b (integer, optional, default: 255)
  • a (integer, optional, default: 255)

Returns

  • integer

colorBrightness(rgba: integer, brightness: float): integer

static

Parameters

  • rgba (integer)
  • brightness (float)

Returns

  • integer

colorOpacity(rgba: integer, opacity: float): integer

static

Parameters

  • rgba (integer)
  • opacity (float)

Returns

  • integer

lerpColorRGB( colorA: integer, colorB: integer, t: float, ): integer

static

Linearly interpolates between two packed RGB colors (0xRRGGBB), channel-wise.

Parameters

  • colorA (integer) — start color, packed RGB (returned at t=0)
  • colorB (integer) — end color, packed RGB (returned at t=1)
  • t (float) — interpolation factor, clamped to 0-1

Returns

  • integer — the interpolated packed RGB color

getControlEventKind( controlCode: integer, charCode: integer, ): BGE.ControlEventKind

static

Tells a remote button event apart from a character typed on a keyboard (e.g. the Roku mobile app's keyboard). A typed character arrives as its own press and release events, and its code can collide with a button code ("d" is 100, the same as a Back release), so check this before treating an event as a button.

Parameters

  • controlCode (integer) — the event's GetInt()
  • charCode (integer) — the event's GetChar()

Returns

getDeviceRenderTier(): DeviceRenderTier

static

Determines this device's render tier via roDeviceInfo.

Not cached internally - CreateObject("roDeviceInfo") plus one or two native calls is cheap enough for the common case (called once, e.g. from a constructor), and this can't change at runtime. A call site that needs to avoid repeating the check across many calls (e.g. once per frame) should cache the returned value itself, the same way Camera3d.getMaxDrawDistanceDeviceCap() already caches its derived cap in an instance field.

Returns

registryWrite( registry_section: string, key: string, value: dynamic, ): boolean

static

Writes a value to the device registry as JSON and flushes it.

Parameters

  • registry_section (string)
  • key (string)
  • value (dynamic) — anything FormatJson() can write

Returns

  • boolean — false if the value can't be written as JSON (e.g. it holds a function or an roBitmap) or the registry refused it (it's full); nothing is written then

registryRead( registry_section: string, key: string, default_value?: dynamic, ): dynamic

static

Reads a value written with registryWrite(). Doesn't write the default.

Parameters

  • registry_section (string)
  • key (string)
  • default_value (dynamic, optional, default: "invalid") — returned when the key is missing

Returns

  • dynamic

registryExists(registry_section: string, key: string): boolean

static

Is there a value for this key?

Parameters

  • registry_section (string)
  • key (string)

Returns

  • boolean

registryDelete(registry_section: string, key: string): void

static

Deletes a key and flushes.

Parameters

  • registry_section (string)
  • key (string)

Returns

  • void

getNumberOfLinesInAString(text: string): integer

static

Gets the number of lines in a string by counting the newlines

Parameters

  • text (string)

Returns

  • integer

lastInStr(text: string, substring: string): integer

static

Finds the index of the last time a substring appears in a string

Parameters

  • text (string)
  • substring (string)

Returns

  • integer

numberToFixed(num: float, precision: integer): string

static

Given a float number, returns the number with a fixed numbers of decimals as a string

Parameters

  • num (float)
  • precision (integer)

Returns

  • string

arrayToStr(things: Array.<dynamic>): string

static

Parameters

  • things (Array.<dynamic>)

Returns

  • string

stringToFloat(input: string): float

static

Parameters

  • input (string)

Returns

  • float

TexturePacker_GetRegions( atlas: dynamic, bitmap: ifDraw2d, ): roAssociativeArray

static

TODO: figure this out... is useful for sprites with different size frames

Parameters

  • atlas (dynamic)
  • bitmap (ifDraw2d)

Returns

  • roAssociativeArray

sliceGridRegions( bitmap: ifDraw2d, cellWidth: integer, cellHeight: integer, ): Array.<roRegion>

static

Slices a bitmap into a row-major grid of cellWidth x cellHeight roRegions.

Parameters

  • bitmap (ifDraw2d)
  • cellWidth (integer)
  • cellHeight (integer)

Returns

  • Array.<roRegion>

ArrayInsert( array: Array.<dynamic>, index: integer, value: dynamic, ): Array.<dynamic>

static

Parameters

  • array (Array.<dynamic>)
  • index (integer)
  • value (dynamic)

Returns

  • Array.<dynamic>

DrawCircleOutline( draw2d: ifDraw2d, line_count: integer, x: float, y: float, radius: float, rgba: integer, ): void

static

Parameters

  • draw2d (ifDraw2d)
  • line_count (integer)
  • x (float)
  • y (float)
  • radius (float)
  • rgba (integer)

Returns

  • void

DrawRectangleOutline( draw2d: ifDraw2d, x: float, y: float, width: float, height: float, rgba: integer, ): void

static

Parameters

  • draw2d (ifDraw2d)
  • x (float)
  • y (float)
  • width (float)
  • height (float)
  • rgba (integer)

Returns

  • void

isValidEntity(entity: EntityWithId): boolean

static

Parameters

Returns

  • boolean

buttonNameFromCode(buttonCode: integer): string

static

Parameters

  • buttonCode (integer)

Returns

  • string

buttonAliasToName(buttonName: string): string

static

Resolves a button name or common alias to the (lowercased) BGE canonical button name, e.g. for use with GameInput.isButton(). Unrecognized names are returned lowercased, unchanged, so a caller checking a name BGE doesn't know about still gets consistent case-insensitive behavior. A gamepad's "a"/"b" face buttons alias to "ok"/"back" here too (A = confirm, B = cancel) - isButton() resolves both sides of its comparison through this table, so an "ok"/"back" check matches a gamepad's A/B press with no extra binding needed.

Parameters

  • buttonName (string) — a button name or alias (case insensitive)

Returns

  • string

cloneArray(original?: Array.<dynamic>): Array.<dynamic>

static

Clone an array (shallow)

Parameters

  • original (Array.<dynamic>, optional, default: "[]") — the original array to be clones

Returns

  • Array.<dynamic> — A shallow copy of the original array

pointArraysEqual( a?: Array.<PositionXY>, b?: Array.<PositionXY>, ): boolean

static

Check if two arrays of points are teh same - that is, if each point, in order has same x and y values

Parameters

  • a (Array.<PositionXY>, optional, default: "[]") — the first array
  • b (Array.<PositionXY>, optional, default: "[]") — the second array

Returns

  • boolean — true if both arrays have same number of points and x and y values are the same for each point

isTrue(value: dynamic): boolean

static

Parameters

  • value (dynamic)

Returns

  • boolean

bytesToInteger( bytes: Array.<integer> | roByteArray, offset?: integer, isLittleEndian?: boolean, ): integer

static

Parameters

  • bytes (Array.<integer> | roByteArray)
  • offset (integer, optional, default: 0)
  • isLittleEndian (boolean, optional, default: true)

Returns

  • integer

bytesToFloat( bytes: Array.<integer> | roByteArray, offset?: integer, isLittleEndian?: boolean, ): float

static

Parameters

  • bytes (Array.<integer> | roByteArray)
  • offset (integer, optional, default: 0)
  • isLittleEndian (boolean, optional, default: true)

Returns

  • float

hexStringToByteArray(hex: string): roByteArray

static

Decodes a hex-encoded string (e.g. from roEVPDigest.Process()) into its raw bytes. Processes hex characters in pairs; an odd-length input's trailing character is decoded as a single nibble (left-padded with implicit zero).

Parameters

  • hex (string)

Returns

  • roByteArray

subArray( array: ifArray, startIndex: integer, length: integer, ): roArray

static

Parameters

  • array (ifArray)
  • startIndex (integer)
  • length (integer)

Returns

  • roArray

decToHex(dec: integer): string

static

Parameters

  • dec (integer)

Returns

  • string

Enums

.GameSessionState

enumreadonly

Where a BGE.GameSession is: waiting to start, playing, paused, game over, or a level won.

Properties

  • ready (default: "ready")
  • playing (default: "playing")
  • paused (default: "paused")
  • over (default: "over")
  • levelComplete (default: "levelComplete")

.TweenApplyMode

enumreadonly

How a managed tween writes its interpolated value onto its target - internal, not part of the public API. "fields" is what to()/addManagedTween() uses for plain named-field targets; the color variants repack channels back into a single packed int instead.

Properties

  • fields (default: "fields")
  • colorRGB (default: "colorRGB")
  • colorRGBA (default: "colorRGBA")

.SeparationPlane

enumreadonly

Which pair of axes BGE.separateCircles() pushes bodies apart on.

Properties

  • xz (default: "xz") — The ground in a 3D game (x and z); height is ignored
  • xy (default: "xy") — A 2D game, e.g. top-down (x and y)

.TileCollisionSide

enumreadonly

Which side of the tile (if any) resolveAabbTileCollision() resolved a collision against. "none" means the tile didn't block the entity at all this frame (e.g. rising through a one-way platform, or no overlap).

Properties

  • none (default: "none")
  • top (default: "top")
  • bottom (default: "bottom")
  • left (default: "left")
  • right (default: "right")

.ParticleShape

enumreadonly

The shape drawn for every particle spawned by a DrawableParticles emitter.

Properties

  • Line (default: "line")
  • Rectangle (default: "rectangle")
  • Image (default: "image")

.PlaneFillMode

enumreadonly

Which of the three composable ways a DrawablePlane fills its surface:

  • color: a flat fill using the drawable's own color/alpha fields, no texture at all. Never "runs out" - the natural base/backdrop layer under the other two.
  • tiledImage: region is treated as a single repeating tile, seamlessly covering the world-space footprint bounded by the camera's maxDrawDistance.
  • staticImage: region is a one-off finite decal anchored at the plane's own world position (today's only historical behavior) - correct for e.g. a map texture, wrong for anything meant to repeat.

Multiple DrawablePlanes (in any mix of modes) can be layered on the same entity or scene via separate addDrawable() calls - draw order for planes at the same depth follows insertion order (SceneObject's existing depth-sort tie-break), so add the base layer (e.g. a color plane) first.

Properties

  • color (default: "color")
  • tiledImage (default: "tiledImage")
  • staticImage (default: "staticImage")

.VoxelPitchMode

enumreadonly

How a voxel terrain follows the camera's pitch. Ignored with a Camera3d.pitchMode "shear" camera, which the terrain always matches exactly.

Properties

  • horizonShift (default: "horizonShift") — Shift the horizon by focal length x tan(pitch): cheapest, but only right near level (about +-15 degrees); past that, objects float or sink against the hills
  • exact (default: "exact") — Project each step with the pitched camera (a divide per step): heights match objects at any pitch, though columns can't lean, so objects near the screen edges drift sideways a little when steeply pitched

.SpritePlayMode

enumreadonly

Properties

  • Loop (default: "loop")
  • Forward (default: "forward")
  • Reverse (default: "reverse")
  • PingPong (default: "pingpong")

.SceneAssetKind

enumreadonly

The kinds of asset a scene can own (see GameScene.loadSceneBitmap() and friends)

Properties

  • bitmap (default: "bitmap")
  • model (default: "model")
  • spriteAtlas (default: "spriteAtlas")
  • tiledMap (default: "tiledMap")
enumreadonly

Where a BGE.NavPathSearch has got to.

Properties

  • searching (default: "searching") — Still running: keep calling step()
  • found (default: "found") — Reached the goal (or the open cell nearest it, if it was blocked)
  • partial (default: "partial") — Couldn't reach the goal; path leads to the cell nearest it (just the start, if the agent is already there)
  • failed (default: "failed") — No path at all: the start is buried in a solid deeper than snapRings, or the goal can't be reached and partial paths are off

.RenderQualityLevel

enumreadonly

Render quality levels, from cheapest to best-looking. See Game.renderQuality, Game.setQualityLevel() and Game.enableAdaptiveQuality().

Properties

  • basic (default: 0)
  • low (default: 1)
  • medium (default: 2)
  • high (default: 3)
  • ultra (default: 4)

.PolygonFillRule

enumreadonly

Which parts of a self-intersecting outline count as inside (SVG's fill-rule).

Properties

  • nonZero (default: "nonzero") — Inside wherever the outline winds round a point at all: a star drawn as one line is solid.
  • evenOdd (default: "evenodd") — Inside wherever a ray from a point crosses the outline an odd number of times: a star drawn as one line has a hollow centre.

.CameraFrustumSide

enumreadonly

Properties

  • top (default: "top")
  • bottom (default: "bottom")
  • left (default: "left")
  • right (default: "right")
  • near (default: "near")

.CameraPitchMode

enumreadonly

How a Camera3d shows its pitch (looking up or down).

Properties

  • rotate (default: "rotate") — Turn the view: a true perspective, where vertical lines converge when pitched
  • shear (default: "shear") — Keep the view level and move the image down (looking up) or up (looking down) by focal length x tan(pitch): vertical lines stay vertical. Matches a voxel terrain's horizon-shift pitch exactly; only reads as looking up or down at modest angles, and pitch is held to +-60 degrees.

.LightType

enumreadonly

Properties

  • ambient (default: "ambient") — Lights every surface equally, whichever way it faces
  • directional (default: "directional") — Shines from infinitely far away in one direction, like the sun
  • point (default: "point") — Shines outward in every direction from one position, like a lamp

.VisibilityState

enumreadonly

Whether a SceneObject was drawn, hidden or off camera last frame. Ordered by how visible each is, so the most visible of several states is simply the largest.

Properties

  • unknown (default: 0)
  • offCamera (default: 1)
  • occluded (default: 2)
  • visible (default: 3)

.OccluderDrawPolicy

enumreadonly

How occluders draw while occlusion culling relies on them (see Renderer.occluderDrawPolicy).

Properties

  • exact (default: "exact") — Occluders always draw exactly - no reused bitmaps, image fast path or coarse fills - and claim their exact outline. Slowest, never glitches.
  • fastShrink (default: "fastShrink") — Occluders take the fast draw paths, and while one may run each occluder's claim is shrunk by that path's worst error, so nothing it doesn't paint is hidden.
  • fastExactClaim (default: "fastExactClaim") — Occluders take the fast draw paths but still claim their exact outline, so an object just behind an occluder's edge can be hidden for a frame while the camera moves.

.SceneObjectType

enumreadonly

Properties

  • Line (default: "Line")
  • Rectangle (default: "Rectangle")
  • Text (default: "Text")
  • Bitmap (default: "Bitmap")
  • Polygon (default: "Polygon")
  • Billboard (default: "Billboard")
  • Model (default: "Model")
  • Plane (default: "Plane")
  • ParallaxLayer (default: "ParallaxLayer")
  • Circle (default: "Circle")
  • Particle (default: "Particle")
  • Skybox (default: "Skybox")
  • Walls (default: "Walls")
  • VoxelTerrain (default: "VoxelTerrain")

.SceneObjectDrawMode

enumreadonly

Properties

  • matchCamera (default: 0) — Rotations are ignored
  • directToCamera (default: 1) — Do not orient in 3d space
  • directScaled (default: 2) — Do not orient in 3d space, but scale in relation to distance from camera
  • oriented (default: 3) — Orient in 3d space
  • orientedDrawBackFace (default: 4) — Orient the object, and draw any back faces
  • wireFrame (default: 5) — Just draw a wire frame
  • wireFrameDrawBackFace (default: 6) — Just draw a wire frame, including back faces
  • solid (default: 7) — Draw a solid polygon
  • solidDrawBackFace (default: 8) — Draw a solid polygon, including back faces
  • axisAligned (default: 9) — Stand upright in the world and turn to face the camera around the vertical axis only, foreshortening with camera pitch - a cylindrical billboard for characters and props

.VoxelHidden

enumreadonly

Where an object sits against the terrain's hills - see SceneObjectVoxelTerrain.testHidden().

Properties

  • visible (default: 0)
  • partly (default: 1)
  • all (default: 2)

.VoxelEdgeMode

enumreadonly

What a BGE.VoxelMap reads past its edges.

Properties

  • wrap (default: "wrap") — The map repeats (it should be tileable)
  • flat (default: "flat") — A floor at flatHeight, coloured palette index flatColor (sea round an island)

.Colors

enumreadonly

- edit scripts/generate-colors.js, not this block The CSS named colors as packed RGBA integers (0xRRGGBBAA), fully opaque. Values match RGBAtoRGBA(r, g, b) for the same named color.

Properties

  • AliceBlue (default: 4042850303)
  • AntiqueWhite (default: 4209760255)
  • Aqua (default: 16777215)
  • Aquamarine (default: 2147472639)
  • Azure (default: 4043309055)
  • Beige (default: 4126530815)
  • Bisque (default: 4293182719)
  • Black (default: 255)
  • BlanchedAlmond (default: 4293643775)
  • Blue (default: 65535)
  • BlueViolet (default: 2318131967)
  • Brown (default: 2771004159)
  • BurlyWood (default: 3736635391)
  • CadetBlue (default: 1604231423)
  • Chartreuse (default: 2147418367)
  • Chocolate (default: 3530104575)
  • Coral (default: 4286533887)
  • CornflowerBlue (default: 1687547391)
  • Cornsilk (default: 4294499583)
  • Crimson (default: 3692313855)
  • Cyan (default: 16777215)
  • DarkBlue (default: 35839)
  • DarkCyan (default: 9145343)
  • DarkGoldenrod (default: 3095792639)
  • DarkGray (default: 2846468607)
  • DarkGreen (default: 6553855)
  • DarkGrey (default: 2846468607)
  • DarkKhaki (default: 3182914559)
  • DarkMagenta (default: 2332068863)
  • DarkOliveGreen (default: 1433087999)
  • DarkOrange (default: 4287365375)
  • DarkOrchid (default: 2570243327)
  • DarkRed (default: 2332033279)
  • DarkSalmon (default: 3918953215)
  • DarkSeaGreen (default: 2411499519)
  • DarkSlateBlue (default: 1211993087)
  • DarkSlateGray (default: 793726975)
  • DarkSlateGrey (default: 793726975)
  • DarkTurquoise (default: 13554175)
  • DarkViolet (default: 2483082239)
  • DeepPink (default: 4279538687)
  • DeepSkyBlue (default: 12582911)
  • DimGray (default: 1768516095)
  • DimGrey (default: 1768516095)
  • DodgerBlue (default: 512819199)
  • FireBrick (default: 2988581631)
  • FloralWhite (default: 4294635775)
  • ForestGreen (default: 579543807)
  • Fuchsia (default: 4278255615)
  • Gainsboro (default: 3705462015)
  • GhostWhite (default: 4177068031)
  • Gold (default: 4292280575)
  • Goldenrod (default: 3668254975)
  • Gray (default: 2155905279)
  • Green (default: 8388863)
  • GreenYellow (default: 2919182335)
  • Grey (default: 2155905279)
  • Honeydew (default: 4043305215)
  • HotPink (default: 4285117695)
  • IndianRed (default: 3445382399)
  • Indigo (default: 1258324735)
  • Ivory (default: 4294963455)
  • Khaki (default: 4041641215)
  • Lavender (default: 3873897215)
  • LavenderBlush (default: 4293981695)
  • LawnGreen (default: 2096890111)
  • LemonChiffon (default: 4294626815)
  • LightBlue (default: 2916673279)
  • LightCoral (default: 4034953471)
  • LightCyan (default: 3774873599)
  • LightGoldenrodYellow (default: 4210742015)
  • LightGray (default: 3553874943)
  • LightGreen (default: 2431553791)
  • LightGrey (default: 3553874943)
  • LightPink (default: 4290167295)
  • LightSalmon (default: 4288707327)
  • LightSeaGreen (default: 548580095)
  • LightSkyBlue (default: 2278488831)
  • LightSlateGray (default: 2005441023)
  • LightSlateGrey (default: 2005441023)
  • LightSteelBlue (default: 2965692159)
  • LightYellow (default: 4294959359)
  • Lime (default: 16711935)
  • LimeGreen (default: 852308735)
  • Linen (default: 4210091775)
  • Magenta (default: 4278255615)
  • Maroon (default: 2147483903)
  • MediumAquamarine (default: 1724754687)
  • MediumBlue (default: 52735)
  • MediumOrchid (default: 3126187007)
  • MediumPurple (default: 2473647103)
  • MediumSeaGreen (default: 1018393087)
  • MediumSlateBlue (default: 2070474495)
  • MediumSpringGreen (default: 16423679)
  • MediumTurquoise (default: 1221709055)
  • MediumVioletRed (default: 3340076543)
  • MidnightBlue (default: 421097727)
  • MintCream (default: 4127193855)
  • MistyRose (default: 4293190143)
  • Moccasin (default: 4293178879)
  • NavajoWhite (default: 4292783615)
  • Navy (default: 33023)
  • OldLace (default: 4260751103)
  • Olive (default: 2155872511)
  • OliveDrab (default: 1804477439)
  • Orange (default: 4289003775)
  • OrangeRed (default: 4282712319)
  • Orchid (default: 3664828159)
  • PaleGoldenrod (default: 4008225535)
  • PaleGreen (default: 2566625535)
  • PaleTurquoise (default: 2951671551)
  • PaleVioletRed (default: 3681588223)
  • PapayaWhip (default: 4293907967)
  • PeachPuff (default: 4292524543)
  • Peru (default: 3448061951)
  • Pink (default: 4290825215)
  • Plum (default: 3718307327)
  • PowderBlue (default: 2967529215)
  • Purple (default: 2147516671)
  • RebeccaPurple (default: 1714657791)
  • Red (default: 4278190335)
  • RosyBrown (default: 3163525119)
  • RoyalBlue (default: 1097458175)
  • SaddleBrown (default: 2336560127)
  • Salmon (default: 4202722047)
  • SandyBrown (default: 4104413439)
  • SeaGreen (default: 780883967)
  • Seashell (default: 4294307583)
  • Sienna (default: 2689740287)
  • Silver (default: 3233857791)
  • SkyBlue (default: 2278484991)
  • SlateBlue (default: 1784335871)
  • SlateGray (default: 1887473919)
  • SlateGrey (default: 1887473919)
  • Snow (default: 4294638335)
  • SpringGreen (default: 16744447)
  • SteelBlue (default: 1182971135)
  • Tan (default: 3535047935)
  • Teal (default: 8421631)
  • Thistle (default: 3636451583)
  • Tomato (default: 4284696575)
  • Turquoise (default: 1088475391)
  • Violet (default: 4001558271)
  • Wheat (default: 4125012991)
  • White (default: 4294967295)
  • WhiteSmoke (default: 4126537215)
  • Yellow (default: 4294902015)
  • YellowGreen (default: 2597139199)

.ColorsRGB

enumreadonly

The CSS named colors as packed RGB integers (0xRRGGBB, no alpha byte) - the same values as BGE.Colors, right-shifted by 8.

Properties

  • AliceBlue (default: 15792383)
  • AntiqueWhite (default: 16444375)
  • Aqua (default: 65535)
  • Aquamarine (default: 8388564)
  • Azure (default: 15794175)
  • Beige (default: 16119260)
  • Bisque (default: 16770244)
  • Black (default: 0)
  • BlanchedAlmond (default: 16772045)
  • Blue (default: 255)
  • BlueViolet (default: 9055202)
  • Brown (default: 10824234)
  • BurlyWood (default: 14596231)
  • CadetBlue (default: 6266528)
  • Chartreuse (default: 8388352)
  • Chocolate (default: 13789470)
  • Coral (default: 16744272)
  • CornflowerBlue (default: 6591981)
  • Cornsilk (default: 16775388)
  • Crimson (default: 14423100)
  • Cyan (default: 65535)
  • DarkBlue (default: 139)
  • DarkCyan (default: 35723)
  • DarkGoldenrod (default: 12092939)
  • DarkGray (default: 11119017)
  • DarkGreen (default: 25600)
  • DarkGrey (default: 11119017)
  • DarkKhaki (default: 12433259)
  • DarkMagenta (default: 9109643)
  • DarkOliveGreen (default: 5597999)
  • DarkOrange (default: 16747520)
  • DarkOrchid (default: 10040012)
  • DarkRed (default: 9109504)
  • DarkSalmon (default: 15308410)
  • DarkSeaGreen (default: 9419919)
  • DarkSlateBlue (default: 4734347)
  • DarkSlateGray (default: 3100495)
  • DarkSlateGrey (default: 3100495)
  • DarkTurquoise (default: 52945)
  • DarkViolet (default: 9699539)
  • DeepPink (default: 16716947)
  • DeepSkyBlue (default: 49151)
  • DimGray (default: 6908265)
  • DimGrey (default: 6908265)
  • DodgerBlue (default: 2003199)
  • FireBrick (default: 11674146)
  • FloralWhite (default: 16775920)
  • ForestGreen (default: 2263842)
  • Fuchsia (default: 16711935)
  • Gainsboro (default: 14474460)
  • GhostWhite (default: 16316671)
  • Gold (default: 16766720)
  • Goldenrod (default: 14329120)
  • Gray (default: 8421504)
  • Green (default: 32768)
  • GreenYellow (default: 11403055)
  • Grey (default: 8421504)
  • Honeydew (default: 15794160)
  • HotPink (default: 16738740)
  • IndianRed (default: 13458524)
  • Indigo (default: 4915330)
  • Ivory (default: 16777200)
  • Khaki (default: 15787660)
  • Lavender (default: 15132410)
  • LavenderBlush (default: 16773365)
  • LawnGreen (default: 8190976)
  • LemonChiffon (default: 16775885)
  • LightBlue (default: 11393254)
  • LightCoral (default: 15761536)
  • LightCyan (default: 14745599)
  • LightGoldenrodYellow (default: 16448210)
  • LightGray (default: 13882323)
  • LightGreen (default: 9498256)
  • LightGrey (default: 13882323)
  • LightPink (default: 16758465)
  • LightSalmon (default: 16752762)
  • LightSeaGreen (default: 2142890)
  • LightSkyBlue (default: 8900346)
  • LightSlateGray (default: 7833753)
  • LightSlateGrey (default: 7833753)
  • LightSteelBlue (default: 11584734)
  • LightYellow (default: 16777184)
  • Lime (default: 65280)
  • LimeGreen (default: 3329330)
  • Linen (default: 16445670)
  • Magenta (default: 16711935)
  • Maroon (default: 8388608)
  • MediumAquamarine (default: 6737322)
  • MediumBlue (default: 205)
  • MediumOrchid (default: 12211667)
  • MediumPurple (default: 9662683)
  • MediumSeaGreen (default: 3978097)
  • MediumSlateBlue (default: 8087790)
  • MediumSpringGreen (default: 64154)
  • MediumTurquoise (default: 4772300)
  • MediumVioletRed (default: 13047173)
  • MidnightBlue (default: 1644912)
  • MintCream (default: 16121850)
  • MistyRose (default: 16770273)
  • Moccasin (default: 16770229)
  • NavajoWhite (default: 16768685)
  • Navy (default: 128)
  • OldLace (default: 16643558)
  • Olive (default: 8421376)
  • OliveDrab (default: 7048739)
  • Orange (default: 16753920)
  • OrangeRed (default: 16729344)
  • Orchid (default: 14315734)
  • PaleGoldenrod (default: 15657130)
  • PaleGreen (default: 10025880)
  • PaleTurquoise (default: 11529966)
  • PaleVioletRed (default: 14381203)
  • PapayaWhip (default: 16773077)
  • PeachPuff (default: 16767673)
  • Peru (default: 13468991)
  • Pink (default: 16761035)
  • Plum (default: 14524637)
  • PowderBlue (default: 11591910)
  • Purple (default: 8388736)
  • RebeccaPurple (default: 6697881)
  • Red (default: 16711680)
  • RosyBrown (default: 12357519)
  • RoyalBlue (default: 4286945)
  • SaddleBrown (default: 9127187)
  • Salmon (default: 16416882)
  • SandyBrown (default: 16032864)
  • SeaGreen (default: 3050327)
  • Seashell (default: 16774638)
  • Sienna (default: 10506797)
  • Silver (default: 12632256)
  • SkyBlue (default: 8900331)
  • SlateBlue (default: 6970061)
  • SlateGray (default: 7372944)
  • SlateGrey (default: 7372944)
  • Snow (default: 16775930)
  • SpringGreen (default: 65407)
  • SteelBlue (default: 4620980)
  • Tan (default: 13808780)
  • Teal (default: 32896)
  • Thistle (default: 14204888)
  • Tomato (default: 16737095)
  • Turquoise (default: 4251856)
  • Violet (default: 15631086)
  • Wheat (default: 16113331)
  • White (default: 16777215)
  • WhiteSmoke (default: 16119285)
  • Yellow (default: 16776960)
  • YellowGreen (default: 10145074)

.ControlEventKind

enumreadonly

What a roUniversalControlEvent represents - see getControlEventKind().

Properties

  • button (default: "button")
  • charPress (default: "charPress")
  • charRelease (default: "charRelease")

.DeviceRenderTier

enumreadonly

Roku hardware performance tier, derived from roDeviceInfo. Every device-tiered branch in the engine (scratch bitmap sizing, low-end draw-quality checks, texture size caps, far-clip distance caps) should switch on this instead of independently re-deriving it from HasFeature("simulation_engine")/GetUIResolution().name.

Properties

  • simulator (default: "simulator")
  • sd (default: "SD")
  • hd (default: "HD")
  • fhd (default: "FHD")

Other

Canvas

static

Contains a roku roBitmap which all game objects get drawn to.

Parameters

  • gameEngine (Game)
  • canvasWidth (integer) — width of canvas
  • canvasHeight (integer) — height of canvas
  • options (RendererOptions, optional, default: "{useBitmapPooling: true}")

Properties

  • bitmap (ifDraw2D) — bitmap GameEntity images get drawn to
  • offset (BGE.Math.Vector) — Position offset from screen coordinates (z value ignored)
  • scale (BGE.Math.Vector) — Scale (z value ignored)
  • renderer (Renderer) — Renderer for this canvas
  • rendererOptions (RendererOptions)

Returns

EmptyBitmapOptions

static

Extends: roAssociativeArray

Size of an empty bitmap for Game.loadBitmap().

Properties

  • width (integer)
  • height (integer)
  • alphaEnable (boolean)

Game

static

Main Game Engine class which runs everything The main game loop is as follows:

  1. Update - For each GameEntity:
  1. Collisions - For each GameEntity:
  • Run Entity's onPreCollision() function
  • For any collisions, runs Entity's onCollision() function
  • Runs entity's onPostCollision() function (At any time, the Entity in question may Delete() itself. Before every entity interaction, the entity is checked to make sure it is still valid in case it was deleted in the last interaction)
  1. Draw - For each GameEntity, sorted by zIndex
  • Runs the Entity onDrawBegin() function
  • For each drawable in the Entity, run the draw() function
  • Run the Entity onDrawEnd() function
  1. Draw all debug items in game space (e.g. colliders, screen safe zones, etc).

  2. UI - For the tree of widgets in the UI Container

  • Run onUpdate()
  • Run draw()
  1. Debug UI - Draw all debug windows in the tree of the Debug UI

Parameters

  • canvasWidth (integer) — Width of the canvas the game is drawn to
  • canvasHeight (integer) — Height of the canvas the game is drawn to
  • uiWidth (integer, optional, default: 0) — Width of the UI canvas (uiCanvas) - if 0, will be same as screen. Lay out gameUi widgets from uiCanvas, not canvas.
  • uiHeight (integer, optional, default: 0) — Height of the UI canvas (uiCanvas) - if 0, will be same as screen

Properties

  • sortedEntities (Array.<GameEntity>)
  • compositor (roCompositor)
  • screen (roScreen)
  • canvas (BGE.Canvas)
  • uiCanvas (BGE.Canvas)
  • dummyScreen (roScreen)
  • textureLoader (BGE.TextureLoader) — Created on first use - see getTextureLoader()
  • renderQuality (BGE.RenderQualityManager) — The game's render quality level and presets - see setQualityLevel(),
  • currentScene (GameScene) — The scene currently in play
  • currentSceneArgs (object) — The args passed to changeScene() for the current scene
  • Entities (object) — All of the GameEntities by name => => GameEntity
  • Statics (object) — All static variables for a given object type
  • Scenes (object) — The scene definitions by name (see defineScene())
  • Interfaces (object) — The interface definitions by name
  • Bitmaps (object) — The loaded bitmaps by name
  • Sounds (object) — The loaded sounds by name
  • Fonts (object) — The loaded fonts by name
  • Models (object) — The loaded Models by name
  • tweenManager (BGE.TweenManager) — Ticks every live tween once per frame and writes interpolated values onto arbitrary
  • screenFade (BGE.ScreenFade) — Full-screen overlay used by changeSceneWithFade() - see BGE.ScreenFade.
  • gameUi (BGE.UI.UiContainer) — Container for all UI
  • keepPauseOnSceneChange (boolean) — Changing scene resumes a paused game (and forgets open modals) unless this is true. A
  • debugUi (BGE.UI.UiContainer) — Container for Debug UI
  • debugToggle (BGE.Debug.DebugToggle) — Steps through debug overlays on a button press - invalid until enableDebugToggle(), or
  • focusManager (BGE.UI.FocusManager) — The single, global focused-widget/cursor state shared by gameUi and any
  • defaultTheme (BGE.UI.Theme) — Default theme for all UI widgets, set in new()
  • assets (BGE.AssetLoader) — Background loader you can use at any time, e.g. to fetch the next level's assets while
  • assetsBudgetMs (integer) — Milliseconds per frame assets may spend on its tasks
  • maxDeltaTime (float) — Longest frame, in seconds, the game's update code sees: a slower frame is treated as
  • loadingBudgetMs (integer) — Milliseconds per frame a scene's loading stage may spend on its tasks
  • loadingScreen (BGE.LoadingScreen) — Loading screen for scenes that don't provide one (GameScene.getLoadingScreen()).
  • uiFocusSoundKey (string) — Default Game.loadSound() keys played by every BGE.UI.Button on focus/click (see
  • uiClickSoundKey (string)
  • controls (BGE.Controller.ControlMap) — Unified remote+controller input mapping - see enableControllerInput()

Returns

GameEntity

static

Every thing (character, player, object, etc) in the game should extend this class. This class has a number of empty methods that are designed to be overridden in subclasses. For example, override onInput() to handle input event, and onUpdate() to handle updating each frame

Parameters

  • game (Game) — The game engine that this entity is going to be assigned to
  • gameEngine (Game)
  • args (roAssociativeArray, optional, default: "{}") — Any extra properties to be added to this entity

Properties

  • name (string) — Constant - name of this Entity
  • id (string | dynamic) — Constant - Unique Id
  • game (Game)
  • enabled (boolean) — Is this GameEntity enabled
  • persistent (boolean) — Does this entity persist across scene changes?
  • pauseable (boolean) — When the game is paused, does this entity pause too?
  • isStatic (boolean) — Marks this entity's drawables as static geometry (walls, props) that never moves
  • hasActiveFlash (boolean) — Set by Drawable.flash() so the game only ticks flashes for entities that have one.
  • position (dynamic) — position of where this entity is in game world
  • velocity (dynamic) — Speed of this entity, in units/second (not units/frame) - added to position each frame scaled by elapsed time
  • rotation (dynamic) — Rotation of entity - applies to all images
  • scale (dynamic) — Scale of entity - applies to all images
  • colliders (roAssociativeArray) — The colliders for this entity by name
  • drawables (Array.<Drawable>) — The array of drawables to draw for this entity
  • drawablesByName (roAssociativeArray) — Associative array of drawables by name
  • tagsList (dynamic) — Game Entities can be tagged with any number of tags so they can be easily identified (e.g. "enemy", "wall", etc.)
  • transformationMatrix (dynamic) — The Current Transformation Matrix
  • motionChecker (MotionChecker)
  • isDying (boolean) — True once invalidateAfter() has been called - lets game code (collision
  • dyingTimer (GameTimer) — Timer/delay backing invalidateAfter()'s grace period. Public (rather than
  • dyingDelayMs (integer)

Returns

CONTROLLER_BUTTON_CODE_PRESS_BASE

staticreadonly

Numeric bands for controller-originated buttonCodes (see BGE.Controller. ControllerRegistry/Game.drainControllerInput, which construct these) - deliberately far above the remote's own 0-99 (press) / 100-999 (release) / 1000+ (held) ranges (see the button-code table below) so a controller event's code can never be misclassified as a remote one. A controller button's identity is a name, not a code (see explicitButtonName below) - these bands exist only to classify press/release/held, so every controller-originated GameInput uses the band's base value as-is.

Default: 100000

CONTROLLER_BUTTON_CODE_RELEASE_BASE

staticreadonly

Default: 200000

CONTROLLER_BUTTON_CODE_HELD_BASE

staticreadonly

Default: 300000

GameInput

static

Class that contains all information about the current input during a given frame from the remote

Parameters

  • buttonCode (integer) — button to use for the data
  • heldTimeMs (integer) — how long was this button held for
  • playerIndex (integer, optional, default: -1) — the assigned player index for this input's source (remote, simulator gamepad, or browser controller); -1 only if none was resolved
  • explicitButtonName (string, optional, default: "invalid") — overrides buttonNameFromCode, used for controller buttons

Properties

  • button (string) — The name of the button associated with the current input
  • buttonCode (integer) — The code for the input
  • press (boolean) — Was the button pressed since the last frame
  • held (boolean) — Was the button held down since last frame
  • release (boolean) — Was the button released this frame
  • heldTimeMs (integer) — How many milliseconds was the current input held for
  • playerIndex (integer) — Which remote/gamepad/controller this input came from. Every physical
  • consumed (boolean) — Set by a UiWidget/UiContainer that acted on this event - once set, the
  • x (float) — Current horizontal directional input: left -> -1, right -> 1
  • y (float) — Current vertical directional input, in world space (+y is up, matching

Returns

Example

CODE
' -------Button Code Reference--------
' Button  Pressed Released  Held
' ------------------------------
' Back         0      100   1000
' Up           2      102   1002
' Down         3      103   1003
' Left         4      104   1004
' Right        5      105   1005
' OK           6      106   1006
' Replay       7      107   1007
' Rewind       8      108   1008
' FastForward  9      109   1009
' Options     10      110   1010
' Backspace   11      111   1011
' Play        13      113   1013
' Enter       15      115   1015

GameScene

static

Extends: GameEntity

A GameScene is a GameEntity that represents one distinct state of your game - a title screen, a menu, a level. Register scenes with Game.defineScene() and switch between them with Game.changeScene(). Only one GameScene is current at a time, and it gets the same per-frame hooks (onUpdate, onInput, ...) as any other entity.

Every scene change destroys all non-persistent entities and, by this class's default onChangeScene(), removes the outgoing scene's own drawables (anything added with addDrawable()/addImage()/etc. directly on the scene). Changing to the current scene again (Game.resetScene(), or changeScene() with the current scene's name, e.g. the next level of a level scene) works exactly like leaving it and entering it again.

To keep some or all of a scene's own drawables across a change:

  • set persistDrawablesAcrossSceneChange = true to keep all of them, or
  • override onChangeScene() with your own cleanup. An override replaces the default cleanup unless it calls super.onChangeScene(newScene).

A scene is defined once and reused: leaving it (or resetting it) calls onChangeScene() then onDestroy() on it, and entering it again runs onLoad()/onCreate() again. Free whatever a visit set up in either hook, or let the scene do it: widgets added with addUi(), lights added with addLight() and assets loaded with loadSceneBitmap() (and friends) go when the game leaves the scene. Widgets added straight to game.gameUi, lights added with game.addLight() and assets loaded straight on the loader stay until you remove them (use those for things that should outlive the scene).

Parameters

  • gameEngine (Game)
  • args (roAssociativeArray, optional, default: "{}")

Properties

  • persistDrawablesAcrossSceneChange (boolean) — Whether this scene's own directly-added drawables survive a scene change (including one
  • qualityOptions (BGE.SceneQualityOptions) — This scene's own render quality settings, applied once it has loaded (after onCreate())
  • trackedSolidWorld (BGE.SolidWorld) — A SolidWorld whose tracked bodies the game resolves every frame, right after
  • sceneUi (Array.<BGE.UI.UiWidget>) — Widgets added with addUi(), removed when this visit ends.
  • sceneAssets (roAssociativeArray) — BGE.SceneAsset by key: what this visit owns (loadSceneBitmap() and friends)
  • releasingSceneAssets (roAssociativeArray) — BGE.SceneAsset by key: the last visit's, between leaving and the next scene's onLoad(),

Returns

GameSessionOptions

static

Extends: roAssociativeArray

Options for BGE.GameSession. Every field is optional.

Properties

  • lives (integer) — Lives at the start of a game (default 0: lives aren't used, so loseLife() does nothing).
  • prompts (boolean) — Show the stock prompt for each state (default false)? See readyPrompt and overPrompt.
  • readyPrompt (string) — Prompt text while ready (default "Press OK To Play").
  • overPrompt (string) — Prompt text once the game's over (default "Game Over!" and "Press OK To Play").
  • pausedPrompt (string) — Prompt text while paused (default none).
  • levelCompletePrompt (string) — Prompt text once a level's complete (default none).
  • startButton (string) — Remote button that starts (or restarts) the game, e.g. "ok" (default "": the game
  • startAction (string) — ControlMap action that starts (or restarts) the game (default "": none).
  • stateEventName (string) — Game event posted when the state changes (default "sessionStateChanged"; "" for none).

GameSessionStateEvent

static

Extends: roAssociativeArray

Data for the game event a BGE.GameSession posts when its state changes.

Properties

  • state (string) — a BGE.GameSessionState value
  • previousState (string) — the state before it

GameSession

static

Extends: BGE.GameEntity

Score, lives and the ready / playing / paused / over / levelComplete flow of an arcade game, as an entity. It keeps the numbers and the state, and posts a game event (stateEventName) when the state changes. Your game keeps its own rules and screens: it calls addScore(), loseLife(), start(), gameOver() and completeLevel() when its own events happen.

Opt in to more: prompts shows a centered "Press OK To Play" / "Game Over!" label (the text is yours to change), startButton/startAction start the game for you, and persistHighScore() keeps the best score in the registry. Subclass and override onStateChanged(), onGameOver() or onLevelComplete() for anything else.

Parameters

Properties

  • score (integer)
  • lives (integer) — Lives left. 0 when lives aren't used.
  • startLives (integer) — Lives a new game starts with. 0 means lives aren't used.
  • highScore (integer) — The best score from the registry (see persistHighScore()), updated when a game ends.
  • state (BGE.GameSessionState)
  • previousState (BGE.GameSessionState)
  • stateEventName (string) — Game event posted with a GameSessionStateEvent when the state changes. "" for none.
  • prompts (boolean) — Show the stock prompt label? Its text comes from the *Prompt fields below.
  • readyPrompt (string)
  • overPrompt (string)
  • pausedPrompt (string)
  • levelCompletePrompt (string)
  • promptLabel (BGE.UI.Label) — The prompt: a centered label in the current scene's UI. Restyle or move it freely.
  • startButton (string) — Remote button that starts the game from ready or over. "" for none.
  • startAction (string) — ControlMap action that starts the game from ready or over. "" for none.
  • profile (BGE.SaveProfile) — Set by persistHighScore().
  • highScoreTable (string)

Returns

Example

CODE
session = new BGE.GameSession(game, {lives: 3, prompts: true, startButton: "ok"})
session.persistHighScore("my-game")
game.addEntity(session)
' When something scores:
session.addScore(10)
' When the player's hit:
if session.loseLife()
' that was the last life - the session is now over
end if

GameTimer

static

Wrapper for Roku's roTimeSpan that allows time adjustment

Returns

PauseMenuOptions

static

Extends: roAssociativeArray

Options for BGE.PauseMenu. Every field is optional.

Properties

  • action (string) — ControlMap action that toggles the menu (default "pause"). Used when it's bound.
  • button (string) — Remote button that toggles the menu when the action isn't bound (default "play").
  • title (string) — Heading (default "Paused").
  • message (string) — Text under the heading (default none).
  • style (string) — "panel" (default): a centered BGE.UI.MenuList of buttons. "text": just the title drawn
  • buttons (Array.<string>) — Button ids, top to bottom (default ["resume", "quit"]). Built in: "resume", "restart"
  • titleScene (string) — Scene the "title" button changes to.
  • closeOnBack (boolean) — Does Back close an open menu (default true)?

PauseMenu

static

Extends: BGE.GameEntity

A pause menu entity: press the toggle (a ControlMap action, or a remote button) to pause the game and show a menu, press it again (or Back, or Resume) to carry on. It opens a modal (Game.pushModal()), so the press that closes it doesn't reach gameplay.

Add it to the game like any entity (make it persistent to keep it across scenes). Customize with options, addButton(), listener, blockWhen, or by subclassing: override onAction() for your own buttons, createMenu() for a different panel, or drawTextStyle() for the "text" look.

Parameters

Properties

  • action (string)
  • button (string)
  • title (string)
  • message (string)
  • style (string)
  • titleScene (string)
  • closeOnBack (boolean)
  • listener (BGE.UI.UiActionListener) — Told about buttons that aren't built in: onUiAction(actionId, button).
  • blockWhen (dynamic) — function(game as BGE.Game) as boolean - return true to keep the menu from opening
  • menu (BGE.UI.MenuList) — The open panel ("panel" style), else invalid.
  • items (Array.<BGE.UI.MenuItem>)

Returns

Example

CODE
pause = new BGE.PauseMenu(game, {buttons: ["resume", "restart", "title"], titleScene: "TitleScene"})
game.addEntity(pause)

SceneCyclerOptions

static

Extends: roAssociativeArray

Options for BGE.SceneCycler. Every field is optional.

Properties

  • nextButton (string) — Button that changes to the next scene (default "fastforward"; "" for none).
  • previousButton (string) — Button that changes to the previous scene (default "rewind"; "" for none).
  • quitOnBack (boolean) — Does the remote's Back button quit the game (default true)?
  • sceneNames (Array.<string>) — The scenes to cycle through, in order (default every scene, in the order they were
  • caption (string) — Hint drawn at the bottom of the screen (default "Change Scene: << / >> | Quit: Back";
  • captionColor (integer) — The caption's color (default white).
  • captionFont (string) — The caption's font key (default "default").

SceneCycler

static

Extends: BGE.GameEntity

Steps through a game's scenes with the remote: Fast Forward/Rewind change to the next or previous scene (wrapping around), Back quits, and a hint along the bottom of the screen says so. Made for demo apps that show one feature per scene.

It's a persistent entity, so add it once (e.g. in main) and it stays across scene changes. Configure it with options, or subclass it: override onSceneChanged() to do something on every change (reset the camera, say), changeToScene() to change scene differently (with a fade), drawCaption() for your own hint, or quit() for what Back does. Set enabled to false to turn it off (hint included) for a while, e.g. in a scene that needs those buttons itself.

Parameters

Properties

  • nextButton (string)
  • previousButton (string)
  • quitOnBack (boolean)
  • sceneNames (Array.<string>) — Empty (the default) means every scene, from Game.getSceneNames() at the time of the change.
  • caption (string)
  • captionColor (integer)
  • captionFont (string)

Returns

Example

CODE
game.defineScene(new FirstScene(game))
game.defineScene(new SecondScene(game))
cycler = new BGE.SceneCycler(game)
game.addEntity(cycler)
game.changeScene(game.getSceneNames()[0])

ScreenFade

static

A full-screen colour overlay drawn on top of the game and its UI, faded in or out over time. Game owns one (game.screenFade) and drives it for Game.changeSceneWithFade(); you can also call fadeTo() on it directly, e.g. to dim the screen behind a pause menu.

Properties

  • color (integer) — Overlay colour, packed RGB (0xRRGGBB)
  • opacity (float) — 0 = invisible, 1 = fully covers the screen

MAX_FADE_STEP_SECONDS

staticreadonly

Longest dt a single ScreenFade.tick() counts (one frame at 30fps) A literal, not 1.0 / 30.0 - the docs plugin can only emit literal const values.

Default: 0.0333333

ManagedTween

static

One tween TweenManager is tracking - internal bookkeeping, not part of the public API a consumer touches directly (that's to()/toColorRGB()/toColorRGBA()/cancel()).

Properties

  • tweenObj (BGE.Tweens.TweenObject)
  • target (object) — The object setAnchor()-style consumers pass to to()/toColorRGB()/toColorRGBA() -
  • applyMode (TweenApplyMode)
  • fieldName (string) — Only set (to the field on target holding the packed color) when applyMode is
  • owner (BGE.GameEntity) — The GameEntity to validate every tick via isValidEntity(), or invalid for a tween
  • onComplete (function) — Called once, with this tween's own target, when it retires - see to()'s doc for why
  • loopMode (BGE.Tweens.TweenLoopMode)
  • delayMs (integer)
  • delayTimer (BGE.GameTimer) — Only non-invalid while a nonzero delay hasn't elapsed yet.
  • originalStart (roAssociativeArray) — The tween's original start/dest fields, before any pingPong ChangeTweenDest() calls
  • originalDest (roAssociativeArray)
  • pingPongForwardNext (boolean)

TweenManager

static

Ticks every live tween once per frame (see Game.tweenManager) and writes interpolated values straight onto arbitrary target object fields - no manual per-frame HandleTween() bookkeeping required. Wraps BGE.Tweens.CreateTweenObject()/HandleTween() per managed tween rather than reimplementing interpolation.

BoxCollider3d

static

Extends: Collider

A collider with the shape of a box CENTERED at (offset.x, offset.y, offset.z), with given width (x), height (y), depth (z), axis-aligned unless turned by yaw. Note this offset convention is center-based, not RectangleCollider's own corner-based convention (see RectangleCollider's class doc) - deliberately simpler, since BoxCollider3d's own 3D math (aabbOverlap()) has no reason to inherit RectangleCollider's screen-space corner convention.

Internally, this owns two ordinary RectangleColliders for broad-phase - one tracking the entity's real (x, y) plane, one tracking a synthetic (y, z) "YZ plane", flagged with COLLIDER_3D_YZ_PLANE_FLAG the same way SphereCollider3d's internal colliders are (see that class's doc comment for why). Unlike SphereCollider3d, this two-plane broad phase has NO false-positive case for boxes - AABB overlap decomposes exactly per axis, so a pair of unturned boxes that passes both plane checks is always a genuine 3D overlap, and confirmCollision() runs aabbOverlap() only for the penetration/normal result. A turned box's broad phase uses the axis-aligned box around it, so confirmCollision() then does reject (orientedBoxOverlap()/sphereOrientedBoxOverlap()). See specs/2026-09-18-3d-collision-detection-design.md.

Parameters

  • colliderName (string) — name of this collider
  • args (roAssociativeArray, optional, default: "{}") — additional properties (e.g {width: 10, height: 20, depth: 10})

Properties

  • width (float) — Full extent of the box along each axis (this is a full width/height/depth, not a half-extent)
  • height (float)
  • depth (float)
  • yaw (float) — Turn about the y axis through the box's centre, in radians, the same way GameEntity.rotation.y
  • lastCollisionResult (Box3dCollisionResult) — The most recent confirmCollision() result, readable from onCollision() to compute a

Returns

CircleCollider

static

Extends: Collider

Collider with the shape of a circle centered at (offset.x, offset.y), with given radius

Parameters

  • colliderName (string) — name of this collider
  • args (roAssociativeArray, optional, default: "{}") — additional properties (e.g {radius: 10})

Properties

  • radius (integer) — Radius of the collider

Returns

CircleBody

static

Extends: roAssociativeArray

One body for BGE.separateCircles(). position is moved in place, so pass the entity's own position vector, e.g. {position: entity.position, radius: 12, mass: 1}.

Properties

  • position (BGE.Math.Vector)
  • radius (float)
  • mass (float) — 0 or less is immovable: only the other body moves

Collider

static

Colliders are attached to GameEntities and when two colliders intersect, it triggers the onCollision() method in the GameEntity

Parameters

  • colliderName (string) — the name this collider will be identified by
  • args (roAssociativeArray, optional, default: "{}") — additional properties to be added to this collider

Properties

  • colliderType (string) — The type of this collider - should be defined in sub classes (eg. "circle", "rectangle")
  • name (string) — Name this collider will be identified by
  • enabled (boolean) — Does this collider trigger onCollision() ?
  • offset (BGE.Math.Vector) — Offset from the GameEntity it is attached to
  • memberFlags (integer) — Bitflag for collision detection: this collider is in this group - https://developer.roku.com/en-ca/docs/references/brightscript/interfaces/ifsprite.md#setmemberflagsflags-as-integer-as-void
  • collidableFlags (integer) — Bitflag for collision detection: this collider will only collider with colliders in this group - https://developer.roku.com/en-ca/docs/references/brightscript/interfaces/ifsprite.md#setcollidableflagsflags-as-integer-as-void
  • compositorObject (roSprite) — Used internal to Game - should not be modified manually
  • owningGame (Game) — Used internal to Game - set by GameEntity.addCollider() so markChanged() can tell the game
  • ownerEntityId (string)
  • contacts (roAssociativeArray) — Used internal to Game - should not be modified manually. Colliders overlapped last frame,
  • tagsList (dynamic) — Colliders can be tagged with any number of tags so they can be easily identified (e.g. "enemy", "wall", etc.)

Returns

COLLIDER_3D_YZ_PLANE_FLAG

staticreadonly

Reserved member/collidable flag bit for SphereCollider3d/BoxCollider3d's internal YZ-plane colliders, which share a roCompositor with ordinary 2D colliders - without this, a YZ-plane collider (positioned at entity.y/z, not a real screen position) could spuriously match a 2D collider whose (x, y) happens to coincide numerically. Avoid this bit when choosing custom memberFlags/collidableFlags. See specs/2026-09-18-3d-collision-detection-design.md.

Default: 1073741824

Sphere3dCollisionResult

static

The result of sphereOverlap(): whether two spheres truly overlap in 3D, and if so, the contact normal (points away from centerB, toward centerA) and how far they're currently penetrating along that normal.

Parameters

  • overlapping (boolean)
  • normal (BGE.Math.Vector)
  • penetrationDepth (float)

Properties

  • overlapping (boolean)
  • normal (BGE.Math.Vector)
  • penetrationDepth (float)

Returns

Box3dCollisionResult

static

The result of aabbOverlap(): whether two axis-aligned boxes truly overlap, and if so, the contact normal (along whichever axis has the least overlap, away from box B and toward box A) and the penetration depth along that axis.

Parameters

  • overlapping (boolean)
  • normal (BGE.Math.Vector)
  • penetrationDepth (float)

Properties

  • overlapping (boolean)
  • normal (BGE.Math.Vector)
  • penetrationDepth (float)

Returns

RAY_EPSILON

staticreadonly

Below this magnitude, a ray's direction component along an axis is treated as exactly zero (parallel to that axis' slab) rather than risking a division by a near-zero value in intersectRayAabb3d()'s slab test.

Default: 0.000001

RaycastHit

static

The result of a raycast hitting a collider - see Game.raycast()/raycastAll(). Pure data, so it's an interface rather than a class (no instantiation cost).

Properties

  • entity (GameEntity)
  • collider (Collider)
  • point (BGE.Math.Vector)
  • distance (float)
  • normal (BGE.Math.Vector)

EntityCollider

static

A collider and the entity that owns it - see Game.getColliders()

Properties

RectangleCollider

static

Extends: Collider

Collider with the shape of a rectangle, width x height, whose top-left corner is at (offset.x, offset.y) from the entity's position. World +y is up, so the rectangle spans offset.x to offset.x + width, and offset.y - height to offset.y.

Parameters

  • colliderName (string) — name of this collider
  • args (roAssociativeArray, optional, default: "{}") — additional properties (e.g {width: 10, height: 20})

Properties

  • width (float)
  • height (float)

Returns

SlideOptions

static

Extends: roAssociativeArray

Options for BGE.SolidWorld.moveAndSlide().

Properties

  • cornerNudge (float) — How far (px) a box moving along one axis may clip a corner and still be eased around it.
  • maxStep (float) — Longest single sub-step (px), so a fast move can't skip over a thin solid. Default 4.

SlideResult

static

Result of BGE.SolidWorld.moveAndSlide().

Properties

  • x (float) — New bottom-left x of the moving box
  • y (float) — New bottom-left y of the moving box
  • blockedX (boolean) — True if a solid stopped movement along x
  • blockedY (boolean) — True if a solid stopped movement along y

SolidTrackOptions

static

Extends: roAssociativeArray

Options for BGE.SolidWorld.track().

Properties

  • plane (BGE.SeparationPlane) — Which two position axes are the SolidWorld's x and y: xz (default, the ground in a 3D
  • slide (BGE.SlideOptions) — Passed to moveAndSlide() each time the body is resolved

SolidTrackable

static

What BGE.SolidWorld.track() needs from a body. Any BGE.GameEntity fits.

Properties

  • id (dynamic) — Invalid once the body is gone (e.g. an invalidated entity), so it's dropped
  • position (BGE.Math.Vector)

SolidWorldTrackedBody

static

Extends: roAssociativeArray

A body BGE.SolidWorld.track() keeps out of solids, and where it was after the last resolve.

Properties

  • entity (BGE.SolidTrackable)
  • entityId (string) — The entity's id when it was tracked: it no longer matches once the entity is invalidated
  • radius (float) — Half the side of the square feet box, centred on the entity's position
  • useY (boolean) — True to use position.y as the SolidWorld's y, false for position.z
  • slide (BGE.SlideOptions)
  • lastX (float) — Where the box centre was after the last resolve
  • lastY (float)

SolidWorldSolid

static

One solid rectangle in a BGE.SolidWorld.

Properties

  • x (float) — Bottom-left x
  • y (float) — Bottom-left y
  • w (float)
  • h (float)
  • id (string) — Unique within its SolidWorld

SolidWorld

static

A set of static, axis-aligned solid rectangles for top-down movement (walls, water, prop bases), and moveAndSlide() to move a box through them: it stops flush against solids, slides along walls, and eases around corners it only just clips.

Every rectangle is {x, y, w, h} - (x, y) is the bottom-left corner, world +y up. This is plain rectangle maths, separate from colliders: colliders report overlaps, while a SolidWorld keeps a mover out of them. For platformer tiles (including one-way platforms) see BGE.resolveAabbTileCollision() instead.

Parameters

  • bucketSize (integer, optional, default: 128) — solids are grouped in square cells this size (px), so a move only tests nearby solids. Roughly the size of a typical solid works well. 0 or less uses the default.

Properties

Returns

Example

CODE
world = new BGE.SolidWorld()
world.addBounds(0, 0, mapWidth, mapHeight)
world.addSolid(64, 64, 32, 32)
' Each frame, move the player's feet box:
result = world.moveAndSlide({x: feetX, y: feetY, w: 20, h: 12}, dx, dy)
feetX = result.x
feetY = result.y

Or track a body and resolve every tracked body once everything has moved it (its own
movement, knockback, being pushed apart): each one's move since the last resolve is replayed
through the solids.
CODE
world.track(knight, 12) ' a 24x24 feet box centred on the knight, on the x/z ground plane
' In GameScene.onPostUpdate(), after BGE.separateCircles():
world.resolveTracked()
' Or have the game call it right after onPostUpdate():
m.trackedSolidWorld = world

SphereCollider3d

static

Extends: Collider

A collider with the shape of a sphere centered at (offset.x, offset.y, offset.z) with given radius, that detects a true 3D overlap - not just an XY-space projection.

Internally, this owns two ordinary CircleColliders for broad-phase: one tracking the entity's real (x, y) - the same XY plane every other 2D Collider uses - and one tracking a synthetic (y, z) "YZ plane", flagged with COLLIDER_3D_YZ_PLANE_FLAG so it can only ever match another YZ-plane collider (both register against the same roCompositor as ordinary 2D colliders, so without this flag a YZ-plane collider could spuriously match an unrelated 2D collider at the same numeric (x, y) position). A pair only becomes a broad-phase candidate when it overlaps on BOTH planes - and even then, confirmCollision() runs a true sphere-sphere distance check before accepting it, because two spheres can pass both plane checks while never actually touching in 3D (a diagonal near-miss). See specs/2026-09-18-3d-collision-detection-design.md.

Parameters

  • colliderName (string) — name of this collider
  • args (roAssociativeArray, optional, default: "{}") — additional properties (e.g {radius: 10})

Properties

  • radius (float) — Radius of the sphere
  • lastCollisionResult (Sphere3dCollisionResult) — The most recent confirmCollision() result, readable from onCollision() to compute a

Returns

TileCollisionResult

static

The result of resolveAabbTileCollision(): the corrected position/velocity to apply this frame, and which side of the tile (if any) was resolved. When side = none, both position and velocity are returned exactly as the currentPosition/velocity inputs were - nothing to apply, safe to write back unconditionally either way.

Parameters

Properties

Returns

FreeFlyCameraController

static

A reusable free-fly camera control scheme: yaw/pitch relative to the camera's current (roll-adjusted) orientation, strafe/drive, roll, and a ground-plane clamp so driving forward can't cross the ground. Not a GameEntity - a GameScene (or any owner) constructs one and forwards its own onInput/onUpdate calls to it. Extracted from examples/terrain's original FreeFlyCameraController (issue #148); that example now layers its own scene-switching/debug-toggle/hint-text glue on top of this.

Movement/look are read each frame from a BGE.Controller.ControlMap's move/look axes (see update()), not from onInput() - a connected dual-stick controller drives full strafe+drive / yaw+pitch, and with no real second stick, both axes fall back to the same remote/simulator source, so the single physical d-pad turns and drives exactly as it always has (see update()'s regime check).

Parameters

  • camera (BGE.Camera3d) — the camera to drive
  • groundPlane (BGE.Math.Plane) — the plane clampAboveGround() keeps the camera above
  • controls (BGE.Controller.ControlMap) — read each update() for the move/look axes
  • moveAxis (string, optional, default: "\"move\"") — axis name bound (via controls.bindAxis()) to the left/drive stick
  • lookAxis (string, optional, default: "\"look\"") — axis name bound (via controls.bindAxis()) to the right/look stick

Properties

  • camera (BGE.Camera3d)
  • groundPlane (BGE.Math.Plane)
  • turnSpeed (float)
  • driveSpeed (integer) — radians/sec
  • rollSpeed (integer) — units/sec
  • pitchSpeed (float) — degrees/sec
  • maxDownwardTilt (float) — radians/sec
  • minHeightAboveGround (float) — radians (~69 degrees)
  • lastInput (BGE.GameInput) — 1 = pitching up, 1 = pitching down, 0 = not pitching

Returns

AnimatedImage

static

Extends: Image

Parameters

  • owner (GameEntity)
  • regions (Array.<roRegion>)
  • args (roAssociativeArray, optional, default: "{}")

Properties

  • index (integer) — The current index of image - this would not normally be changed manually, but if you wanted to stop on a specific image in the spritesheet this could be set.
  • animationDurationMs (float) — The time in milliseconds for a single cycle through the animation to play.
  • animationTween (string) — The name of the tween to use for choosing the next image
  • regions (Array.<roRegion>) — ------------Never To Be Manually Changed-----------------
  • animationTimer (dynamic)
  • tweensReference (dynamic)

Returns

Drawable

static

Abstract drawable class - all drawables extend from this

Parameters

  • owner (GameEntity)
  • args (roAssociativeArray, optional, default: "{}")

Properties

  • name (string) — -------------Values That Can Be Changed------------
  • offset (dynamic) — The offset of the image from the owner's position
  • scale (dynamic) — The image scale
  • rotation (dynamic) — Rotation of the image
  • banksWithCameraRoll (boolean) — directScaled only (see SceneObjectBillboard.updateCanvasPointsForCameraFacingQuad()):
  • axisAlignedFullHeightPitch (float) — axisAligned only: the angle (degrees) the camera looks down at this drawable from when
  • color (integer) — This can be used to tint the image with the provided color if desired. White makes no change to the original image.
  • outlineRGBA (integer) — RGB color for the outline stroke. Leave invalid for no outline at all.
  • outlineWidth (integer) — Thickness of the outline stroke, in pixels. Only used when outlineRGBA is set.
  • alpha (float) — Change the image alpha (transparency).
  • enabled (boolean) — Whether or not the image will be drawn.
  • transformationMatrix (dynamic)
  • motionChecker (MotionChecker)
  • shouldRedraw (boolean)
  • geometryVersion (integer) — Bumped every time this drawable's geometry changes in a way the
  • anchor (dynamic) — Normalized anchor point (0-1 on each axis) this drawable pivots around, where (0,0) is
  • anchorIsSet (boolean) — Whether setAnchor() has ever been called. Image consults this to decide whether to keep
  • owner (GameEntity) — The GameEntity this drawable is attached to. May be invalid for a drawable used
  • width (float)
  • height (float)
  • sceneObjects (object)
  • noOwnerTransformationMatrix (Array.<Array.<float>>) — Lazily-created identity matrix returned by getOwnerTransformationMatrix() when there's no owner.
  • drawMode (SceneObjectDrawMode)
  • isOccluder (boolean) — Makes this drawable hide whatever sits behind it (occlusion culling). Only takes
  • castsFogSilhouette (boolean) — Keeps blocking the sky past the draw distance, in the camera's fog colour, while its fog
  • fadesWithDistance (boolean) — Whether this drawable fades out near a 3D camera's draw distance (see
  • fadeDistanceScale (float) — Fades out and stops drawing as if a 3D camera's draw distance were this many times as
  • isShaded (boolean) — Whether this drawable is darkened by lighting: by the renderer's lights (see
  • lightWrap (float) — How far an isShaded drawable's lights wrap round past the side facing them, 0-1.
  • ambientBrightness (float) — The darkest an isShaded surface is ever allowed to get, as a 0-1 fraction of its

Returns

DrawableCircle

static

Extends: Drawable

Draws a filled circle via the renderer's shared circle texture (see Renderer.getCircleResource()), with an optional outline stroked as a regular polygon inscribed in the circle's own quad - see SceneObjectCircle.

Like DrawableRectangle, the circle's top left (of its bounding square) sits at the drawable's own world position, extending radius * 2 right and down - so it anchors and composes with the rest of the engine the same way every other drawable does. In the oriented/solid/wireFrame 3D draw modes it foreshortens into an ellipse when viewed at an angle, the same as any other billboard (see DrawableSphere for a circle that never does this).

Parameters

  • owner (GameEntity)
  • radius (float)
  • args (roAssociativeArray, optional, default: "{}")

Properties

  • radius (float)
  • outlineSegments (integer) — Regular-polygon segment count used only for the outline - the fill is a texture

Returns

DrawableGridWalls

static

Extends: BGE.DrawableWalls

The walls of a grid maze: a BGE.DrawableWalls whose segments come from the map (GridWallsMap.toSegments()), one per straight run of a texture, facing the open cells. Needs a Camera3d; one walls drawable per renderer.

isShaded lights the walls; color/alpha tint them, and flash() works as for other drawables.

Parameters

  • owner (BGE.GameEntity)
  • map (BGE.GridWallsMap)
  • textures (roAssociativeArray) — texture name (as used in the map's legend) to an roRegion one cell wide and the wall height tall
  • args (roAssociativeArray, optional, default: "{}") — Drawable fields, e.g. {isShaded: true}; hideTolerance defaults to a quarter cell

Properties

  • map (BGE.GridWallsMap) — The grid whose solid cells are drawn as walls. Replace it with setMap(), or call setMap()

Returns

DrawableLine

static

Extends: Drawable

Parameters

  • owner (GameEntity)
  • startPos (BGE.Math.Vector)
  • endPos (BGE.Math.Vector)
  • args (roAssociativeArray, optional, default: "{}")

Properties

  • startPosition (BGE.Math.Vector)
  • endPosition (BGE.Math.Vector)

Returns

OrientedSpriteBucket

static

One resolved angle/elevation bucket: its own registered Sprite animation name.

Properties

  • animationName (string)

DrawableOrientedSprite

static

Extends: Sprite

A Sprite that swaps which named animation is active based on the angle between the camera and this entity - the classic Doom/Duke3D "billboard sprite" technique for faking full 3D orientation with pre-rendered 2D views. See docs/drawables-and-scene-objects.md for a full walkthrough and specs/2026-09-22-oriented-sprite-billboards-design.md for the design.

Parameters

  • owner (GameEntity)
  • spriteSheet (ifDraw2d | Array.<ifDraw2d> | BGE.SpriteFrames)
  • cellWidth (integer)
  • cellHeight (integer)
  • numAngles (integer, optional, default: 8)
  • numElevationBands (integer, optional, default: 1)
  • args (roAssociativeArray, optional, default: "{}")

Properties

  • numAngles (integer) — Number of horizontal (azimuth) view buckets around the entity. Bucket 0 is the
  • numElevationBands (integer) — Number of vertical (elevation) view bands, from the camera looking up at the
  • mirrorBuckets (boolean) — Halves the sheet for a roughly left/right-symmetric character: register only buckets 0
  • lodDistance (float) — Animation level of detail: past this level distance (world units, across x/z) from the camera, an animation
  • lodCheckSeconds (float) — How often (seconds) the distance is rechecked. After the first check (on the first

Returns

DrawableParallaxLayer

static

Extends: Drawable

Scrolls a tiled/non-tiled bitmap layer at a configurable per-axis fraction of the camera's movement (parallax). {1,1} is the default and behaves exactly like an ordinary drawable; {0,0} pins the layer to the camera; 0 < factor < 1 is a background layer that drifts slower than the world; factor > 1 is a foreground layer that scrolls faster. See SceneObjectParallaxLayer for the actual per-frame math.

Combines with the owning entity's position/offset exactly like every other Drawable - there is no special "independent of owner" positioning mode. Attach this to a dedicated static entity if you want a fixed background anchor.

This is also the right tool for a 2D sky-like background (issue #145): BGE.Skybox is a yaw/pitch-driven cylindrical panorama, Camera3d-only. For a Camera2d scene, a wide region with a small parallaxFactor (e.g. {x: 0.1, y: 0.1}) gives the same "shifts slowly with the camera" feel without needing any dedicated skybox-for-2D mechanism.

Parameters

  • owner (BGE.GameEntity)
  • region (roRegion)
  • args (roAssociativeArray, optional, default: "{}")

Properties

  • region (roRegion) — The bitmap tile to scroll/repeat.
  • parallaxFactor (BGE.Math.Vector) — Per-axis fraction of camera movement this layer scrolls at. See the class doc for
  • repeatX (boolean) — Whether this layer tiles to cover the canvas along each axis. repeatX defaults true
  • repeatY (boolean)

Returns

ParticleRecord

static

One live particle spawned by a DrawableParticles emitter.

Properties

  • position (BGE.Math.Vector)
  • velocity (BGE.Math.Vector)
  • age (float)
  • lifetime (float)
  • startColor (integer)
  • endColor (integer)
  • startAlpha (float)
  • endAlpha (float)
  • startSize (float)
  • endSize (float)
  • rotation (float)

DrawableParticles

static

Extends: Drawable

Emits and simulates lightweight particles (lines, rectangles, or images) with randomized velocity, constant acceleration, and lifetime-driven fade/color/size interpolation. Draws through a single SceneObjectParticle per emitter rather than one SceneObject per particle, so spawning/expiring particles never touches Renderer.addSceneObject/removeSceneObject - see specs/2026-08-18-particle-system-design.md for why that matters for depth-sort performance.

Parameters

Properties

  • shape (ParticleShape) — Shape drawn for every particle. See BGE.ParticleShape.
  • image (dynamic) — Bitmap or region drawn for each particle when shape = BGE.ParticleShape.Image.
  • cellWidth (integer) — Width/height (pixels) of one animation cell if image is a sprite sheet, the
  • cellHeight (integer)
  • regions (Array.<roRegion>)
  • spawnRate (float) — Particles spawned per second while emitting (see start()/stop()).
  • lifetime (float) — Base lifetime in seconds each particle survives, randomized by +/- lifetimeSpread.
  • lifetimeSpread (float)
  • velocity (BGE.Math.Vector) — Base emission velocity (world units/second) shared by every particle before
  • velocitySpreadAngleDegrees (float) — Randomizes each particle's velocity direction by +/- this many degrees around
  • velocitySpreadMagnitude (float) — Randomizes each particle's velocity magnitude by +/- this amount. If velocity
  • acceleration (BGE.Math.Vector) — Constant acceleration (world units/second^2) applied to every particle every
  • startColor (integer) — Packed RGB (0xRRGGBB) color interpolated over each particle's lifetime.
  • endColor (integer)
  • startAlpha (float) — Alpha (0-255) interpolated over each particle's lifetime.
  • endAlpha (float)
  • startSize (float) — Size interpolated over each particle's lifetime - a line's length (world units), a
  • endSize (float)
  • sizeInWorldUnits (boolean) — When true, a rectangle's side is in world units and an image's scale multiplies its
  • rotationSpeed (float) — Degrees/second of rotation applied to each particle. Only used when
  • maxParticles (integer) — Hard cap on live particles. Once reached, further spawns (continuous emission or
  • particles (Array.<BGE.ParticleRecord>) — Live particle records. See BGE.ParticleRecord.
  • emitting (boolean)
  • spawnAccumulator (float)
  • timer (dynamic)

Returns

DrawablePlane

static

Extends: BGE.Image

Used to draw a "infinite" plane in 3d space Ideally used for a ground or floor

Parameters

  • owner (BGE.GameEntity)
  • region (roRegion) — the texture tile to use for tiledImage/staticImage fillMode - pass invalid for color fillMode, which ignores it entirely. An invalid region with any other fillMode logs an error and falls back to color rather than crashing later inside the renderer.
  • plane (BGE.Math.Plane)
  • args (object, optional, default: "{}") — pass fillMode here to select a mode other than the default staticImage - e.g. {fillMode: BGE.PlaneFillMode.color}.

Properties

  • plane (BGE.Math.Plane)
  • fillMode (PlaneFillMode)
  • lightPoolOpacity (float) — How strongly a point light's pool covers the ground at its brightest, 0-1, on an
  • bakesLightPools (boolean) — Whether an isShaded staticImage plane draws its lighting, pools included, into a lit

Returns

DrawablePolygon

static

Extends: Drawable

Parameters

  • owner (GameEntity)
  • points (Array.<BGE.Math.Vector>, optional, default: "[]")
  • args (roAssociativeArray, optional, default: "{}")

Properties

  • points (Array.<BGE.Math.Vector>) — The polygon's corners. Filled as their convex hull (in any order) unless concave.
  • concave (boolean) — Fill the outline as drawn, notches and all, rather than its convex hull: the points
  • fillRule (BGE.PolygonFillRule) — With concave, what's inside a self-intersecting outline: nonzero (a star drawn as one

Returns

DrawableRectangle

static

Extends: Drawable

Draws a rectangle, filled and/or outlined.

The rectangle's top left corner sits at the drawable's own world position (its offset transformed by the owning entity), extending width to the right and height downwards on screen - the same anchoring an Image uses, so the two are interchangeable.

In the direct (billboard) draw modes - which is what a 2D game gets, since a Camera2d resolves matchCamera to directToCamera - this is a plain axis-aligned rectangle. In the oriented/solid/wireFrame draw modes it becomes a quad that rotates and foreshortens in 3D like any other billboard (see examples/3d's RectanglesScene).

Set color for the fill and outlineRGBA for the outline (both packed RGB, no alpha byte - alpha is separate). Leaving outlineRGBA unset means no outline at all; set filled = false for an outline-only rectangle.

Parameters

  • owner (GameEntity)
  • width (float)
  • height (float)
  • args (roAssociativeArray, optional, default: "{}")

Properties

  • filled (boolean) — Whether the rectangle's interior is filled with color. Set false for an outline-only

Returns

DrawableSkybox

static

Extends: BGE.Image

Draws a cylindrical panorama that tracks the camera's yaw/pitch (and, via a render-then-rotate composite, roll), giving a Camera3d scene a sky/horizon background instead of a flat fill. See SceneObjectSkybox for the draw algorithm.

Parameters

  • owner (BGE.GameEntity)
  • region (roRegion) — a cylindrical panorama texture
  • args (object, optional, default: "{}") — pass degreesPerFullWidth/verticalDegreesCovered here to override the defaults

Properties

  • degreesPerFullWidth (float) — How many degrees of camera yaw the texture's full width covers. Default wraps a
  • verticalDegreesCovered (float) — How many degrees of camera pitch the texture's full height covers, centered on

Returns

DrawableSphere

static

Extends: DrawableCircle

A circle that always looks the same from any camera angle, because a sphere looks the same from every direction. Everything about the fill/outline is identical to DrawableCircle (which this extends unchanged, including addToRenderer) - the only difference is forcing drawMode to directScaled in the constructor, which billboards (never rotates/foreshortens) while still scaling with camera distance in 3D. See SceneObject.getActualDrawMode(): it only resolves the matchCamera default through the camera, so any other explicit drawMode - this one included - is used as-is.

Deliberately does NOT re-append args after forcing drawMode (DrawableCircle's own constructor already applied them once) - a caller passing {drawMode: ...} here should not be able to silently defeat a DrawableSphere's entire reason for existing. A caller who genuinely wants a different draw mode can still assign sphere.drawMode = ... directly after construction.

Parameters

  • owner (GameEntity)
  • radius (float)
  • args (roAssociativeArray, optional, default: "{}")

Returns

MIN_TEXT_REGION_SIZE

staticreadonly

Default: 256

DrawableText

static

Extends: Drawable

Class to draw text

Parameters

  • owner (GameEntity)
  • text (string, optional, default: "\"\"")
  • font (roFont, optional, default: "invalid")
  • args (roAssociativeArray, optional, default: "{}")

Properties

  • text (string) — The text to write on the screen
  • font (roFont) — The Font object to use ( get this from the font registry)
  • alignment (BGE.UI.HorizAlignment) — The Horizontal alignment for the text
  • textColor (integer) — The color the text is drawn in
  • lastTextValue (string)
  • lastTextColor (integer)
  • tempCanvas (roBitmap)
  • tempRegion (roRegion)
  • lastAlignment (BGE.UI.HorizAlignment)
  • imageAlignment (string) — The alignment the cached text image was drawn with

Returns

DrawableVoxelTerrain

static

Extends: BGE.Drawable

Hills from a heightmap (a BGE.VoxelMap), drawn Comanche-style: each screen column marches over the map front to back and draws a vertical span wherever the terrain rises into view. Retro and low resolution (quality sets the columns), but real hills a flat DrawablePlane can't give. Camera3d only, one per renderer.

The owner's position plus offset is map cell (0, 0): map x and z are world x and z (times cellSize), and a map height (0-255) is heightScale world units above the owner. The terrain is drawn after the planes and before the walls, and hides sorted objects behind its hills. Roll works at any angle; pitch is limited by pitchMode. With Camera3d.fog on, the terrain fades into the fog; otherwise set fade.

See docs/voxel-terrain.md.

Parameters

  • owner (BGE.GameEntity) — its position is map cell (0, 0)
  • map (BGE.VoxelMap)
  • args (roAssociativeArray, optional, default: "{}") — any of the fields above

Properties

  • map (BGE.VoxelMap) — The heightmap
  • cellSize (float) — World units per map cell
  • heightScale (float) — World units per height unit (the map's 0-255 scale)
  • pitchMode (string) — BGE.VoxelPitchMode
  • fade (dynamic) — With Camera3d.fog off: {color: 0xRRGGBB, start: 0.5} fades far terrain into color
  • hideTolerance (float) — How much nearer than an object's middle the terrain must be to hide it, in world units.

Returns

DrawableWall

static

Extends: BGE.Image

A freestanding upright wall at any angle: a textured quad between two floor points, from bottom to top, in its owner's space. Set tileWidth/tileHeight to repeat the texture along a long or tall wall instead of stretching it. Draws as perspective-correct columns on a Camera3d.

Give the owning GameEntity isStatic = true so walls sort through the static BSP and can occlude. Each wall is its own sorted object, so cost grows with the wall count (unlike BGE.DrawableWalls), and walls that cross each other can sort wrong. No collision.

Parameters

  • owner (BGE.GameEntity)
  • region (roRegion) — the texture
  • startPoint (BGE.Math.Vector) — a floor end (x, z)
  • endPoint (BGE.Math.Vector) — the other floor end
  • bottom (float)
  • top (float)
  • args (roAssociativeArray, optional, default: "{}") — any other fields (e.g. tileWidth, tileHeight, drawMode)

Properties

  • startPoint (BGE.Math.Vector) — One floor end, in the owner's space (x and z; y is ignored)
  • endPoint (BGE.Math.Vector) — The other floor end
  • bottom (float) — Height of the wall's foot and top, in the owner's space
  • top (float)
  • tileWidth (float) — World units one copy of the texture covers across, or 0 to stretch it over the whole wall
  • tileHeight (float) — World units one copy of the texture covers up, or 0 to stretch it. Tiles start at the foot.

Returns

Example

CODE
wall = new BGE.DrawableWall(m, brickRegion, {x: 0, z: 0}, {x: 400, z: -200}, 0, 120, {tileWidth: 64, tileHeight: 64})
m.addDrawable("wall", wall)

DrawableWalls

static

Extends: BGE.Drawable

A level's walls: upright segments at any angle, each with its own foot and top height, in world space (see BGE.createWallSegment()). Drawn on a Camera3d as leaning texture-column strips, wallStripWidth pixels apart (see BGE.RenderQualitySettings), in the renderer's walls stage, after planes and before the sorted objects; one walls drawable per renderer (BGE.DrawableGridWalls included).

Cost follows how much of the screen walls cover, not how many there are. Short walls let taller ones behind show, and sprites, models and drawWorld* overlays behind walls are hidden. Wall tops aren't drawn; pitch about 15 degrees up to 35 down; roll is ignored. Nothing may sit below the lowest wall foot. No collision.

The walls are put in a 2D BSP when set (in new() and setSegments(), not while drawing), so they're walked in exact front to back order from anywhere; walls that cross are split where they meet.

isShaded lights each wall along its length; color/alpha tint them, and flash() works as for other drawables.

Parameters

  • owner (BGE.GameEntity)
  • segments (Array.<BGE.WallSegment>)
  • textures (roAssociativeArray) — texture name to roRegion
  • args (object, optional, default: "{}") — Drawable fields, e.g. {isShaded: true}

Properties

  • segments (Array.<BGE.WallSegment>) — The walls. Call setSegments() to replace them, or after changing them in place.
  • bsp (BGE.WallsBsp) — The BSP the walls are walked by, built from segments by setSegments(). Read-only.
  • textures (roAssociativeArray) — Texture name to an roRegion: one copy of the texture as tiled on a wall. Change with
  • hideTolerance (float) — How much nearer than an object a wall must be to hide it, in world units of depth.
  • lightBucketLength (float) — World units of wall length each lit color is shared along.
  • maxColumnHeight (integer) — Tallest stacked column texture built, in pixels; taller walls stretch fewer copies.
  • mipmapped (boolean) — Strips wider than a texture column draw from a coarser copy, each column the average of

Returns

Example

CODE
segments = [
BGE.createWallSegment({x: 0, z: 0}, {x: 512, z: 0}, 0, 128, "stone", {tileWidth: 64, tileHeight: 128})
BGE.createWallSegment({x: 512, z: 0}, {x: 512, z: 512}, 0, 32, "stone", {tileWidth: 64, tileHeight: 32, twoSided: true})
]
walls = new BGE.DrawableWalls(m, segments, {stone: stoneRegion}, {isShaded: true})
m.addDrawable("walls", walls)

Image

static

Extends: BGE.Drawable

Used to draw a bitmap image to the screen

Parameters

  • owner (BGE.GameEntity)
  • region (roRegion)
  • args (roAssociativeArray, optional, default: "{}")

Properties

  • regionId (string) — An optional unique name for the region, used for caching image data. If not provided, the name of the drawable will be used as the region name.
  • region (roRegion) — ------------Never To Be Manually Changed-----------------

Returns

Model3dTexture

static

Parameters

  • srcRegionWithId (BGE.RendererHelpers.RegionWithId)
  • points (Array.<BGE.Math.Vector>)

Properties

  • srcRegionWithId (BGE.RendererHelpers.RegionWithId)
  • points (Array.<BGE.Math.Vector>)

Returns

Model3dLoadOptions

static

The options accepted by Game.load3dModel() for an .obj model's texture.

Properties

  • texturePath (string) — A texture to draw every textured face with, instead of the textures its .mtl file gives

Model3dMaterial

static

A material from an .obj model's .mtl file (a newmtl block).

Properties

  • name (string)
  • texturePath (string) — Its texture (map_Kd), resolved against the .mtl file's folder or URL; "" if it has none
  • color (integer) — Its diffuse color (Kd) as packed RGBA - what a face with this material is filled with

Model3dFace

static

Properties

  • vertices (Array.<BGE.Math.Vector>)
  • normal (BGE.Math.Vector)
  • Texture (Model3dTexture)
  • material (string) — The name of this face's material (the .obj's usemtl), if it has one
  • brightness (float)
  • shadedColor (integer) — The color to draw with: color after shading - set on the per-frame canvas-space copy
  • priority (float)
  • color (integer)
  • faceIndex (integer) — This face's position in the model's own, never-reordered face list - set on the

MODEL_TILED_TEXTURE_MAX_SIZE

staticreadonly

The largest a model texture tiled for UVs past 0..1 may be on each side, in pixels (half this on an HD or SD device - see Model3dOps.getTiledTextureMaxSize())

Default: 1024

UVTileRange

static

The whole texture repeats a face's UVs cover - see Model3dOps.getUVTileRange()

Properties

  • minU (integer)
  • maxU (integer)
  • minV (integer)
  • maxV (integer)

ModelFaceTexture

static

A texture (or a tiled copy of one) that faces map their UVs into

Properties

  • regionWithId (BGE.RendererHelpers.RegionWithId)
  • tileWidth (float) — the size of one repeat of the texture, in pixels
  • tileHeight (float)

BoxFacesOptions

static

The options accepted by Model3dOps.boxFaces().

Properties

  • omit (Array.<string>) — Sides to leave out: "top" (+y), "bottom" (-y), "right" (+x), "left" (-x), "front" (+z)

ImpostorOptions

static

Extends: roAssociativeArray

DrawableModel.applyImpostorOptions()'s options. Each is a native value or a string, as deep-link params arrive ("1"/"true"/"0"/"false" for booleans); one that's missing or won't parse leaves its field alone.

Properties

  • impostor (dynamic) — useImpostor
  • strips (dynamic) — useImpostorStrips
  • stripStep (dynamic) — impostorStripStepPx
  • stripWidth (dynamic) — impostorStripWidth
  • stripKnots (dynamic) — impostorStripKnots
  • stripPoints (dynamic) — impostorStripMaxPoints
  • stripError (dynamic) — impostorStripMaxError
  • stripMax (dynamic) — impostorStripMaxStrips
  • stripAngle (dynamic) — impostorStripMaxAngleDegrees
  • stripScale (dynamic) — impostorStripErrorScale
  • stripLinear (dynamic) — not impostorStripPerspective: true fits the strips linearly in screen x
  • stripLevel (dynamic) — impostorStripLevel
  • blitScale (dynamic) — impostorBlitErrorScale
  • blitAngle (dynamic) — impostorBlitMaxAngleDegrees
  • blitAngleScale (dynamic) — impostorBlitAngleScale
  • blitDepth (dynamic) — impostorBlitMaxDepthRatio
  • blitRoll (dynamic) — impostorBlitRollOnly
  • newFace (dynamic) — impostorRedrawOnNewFace
  • newFaceArea (dynamic) — impostorNewFaceMinArea

Model3d

static

Parameters

Properties

  • faces (Array.<Model3dFace>)
  • name (string)
  • texturePath (string) — The texture for faces with no material: the first map_Kd in the .obj's .mtl file
  • materials (roAssociativeArray) — The materials from the .obj's .mtl file, by name (Model3dMaterial)

Returns

DrawableModel

static

Extends: Drawable

Parameters

Properties

  • model (Model3d) — The model to draw. After replacing it or changing its faces, call
  • useImpostor (boolean) — Experimental (#345, specs/2026-10-22-model-impostors-design.md): while the camera
  • impostorBlitRollOnly (boolean) — Experimental (#556): rotate the impostor's single blit only to follow the camera's roll.
  • useImpostorStrips (boolean) — Experimental (#556): when the impostor's single scaled blit no longer fits, try redrawing
  • impostorStripStepPx (float) — How far (px) a strip's single vertical scale may leave any of its columns from the
  • impostorStripWidth (integer) — A fixed strip width, in pixels of the captured bitmap. 0 sizes strips by
  • impostorStripKnots (integer) — Where the strips' hint points come from: 0 fits them to the bounding box's visible
  • impostorStripMaxPoints (integer) — The most visible vertices a strip fit uses (an evenly spread subset of them): each
  • impostorStripPerspective (boolean) — Interpolate the strips with perspective between hint points, exact for flat walls between
  • impostorStripMaxError (float) — How far (px) the strips may put any visible vertex from where it really is before the
  • impostorStripMaxStrips (integer) — The most strips one redraw may take; past it the model is redrawn instead.
  • impostorStripMaxAngleDegrees (float) — How far (degrees) the view may turn from the capture's and still try strips. 0 keeps the
  • impostorBlitErrorScale (float) — Strips are the middle tier between the single blit and a redraw: with them on, the single
  • impostorBlitMaxAngleDegrees (float) — With strips on, how far (degrees) the view may turn before the single blit hands over to
  • impostorBlitMaxDepthRatio (float) — How far the model may reach in depth, as a multiple of its nearest point's depth, and
  • impostorBlitAngleScale (float) — With strips on, scales the single blit's angle limit (the quality level's, or
  • impostorRedrawOnNewFace (boolean) — Redraw the impostor, at any quality level, once a side of the model that faced away at
  • impostorNewFaceMinArea (float) — Sides smaller than this fraction of the model's whole surface (a plane's faces added up)
  • impostorStripErrorScale (float) — Scales the quality level's modelImpostorError for strips, so they can hold on longer than
  • impostorStripLevel (boolean) — Fit the strips in a level view (no pitch or roll) and turn each strip as it's drawn, so

Returns

ParticleBurstStyle

static

Extends: roAssociativeArray

What one ParticleBurstPool.play() burst looks like. Random spreads are +/- around the value.

Properties

  • shape (BGE.ParticleShape)
  • count (integer)
  • startColor (integer) — RGB (0xRRGGBB), over each particle's life
  • endColor (integer)
  • startAlpha (float) — 0-255; default 255 to 0, so particles fade out
  • endAlpha (float)
  • startSize (float) — See DrawableParticles.startSize
  • endSize (float)
  • sizeInWorldUnits (boolean) — See DrawableParticles.sizeInWorldUnits; default false
  • lifetime (float) — Seconds
  • lifetimeSpread (float)
  • spreadRadians (float) — Cone around the play() direction; see DrawableParticles.burstCone()
  • speed (float)
  • speedSpread (float)
  • lift (float)
  • liftSpread (float)
  • acceleration (BGE.Math.Vector) — Constant acceleration, e.g. gravity (0, -500, 0)

ParticleBurstPool

static

Extends: GameEntity

Plays one-shot particle bursts anywhere in the world (hits, sparks, dust) from a small pool of emitters, so a burst doesn't create an entity, emitter and scene object each time. An emitter is reused once its particles have faded. Add one to the game, e.g. in a scene's onCreate():

m.bursts = new BGE.ParticleBurstPool(m.game) m.game.addEntity(m.bursts) m.bursts.play(hitPoint, swingDirection, bloodStyle)

Parameters

  • game (BGE.Game)
  • args (roAssociativeArray, optional, default: "{}")

Properties

  • maxEmitters (integer) — Most emitters it will make. When all are busy, play() drops the burst.
  • emitters (Array.<BGE.DrawableParticles>)

Returns

ParticlePresetOptions

static

Extends: roAssociativeArray

Options for BGE.ParticlePresets. Every field is optional.

Properties

  • unitsPerMetre (float) — World units per metre: preset sizes, speeds and gravity are in metres. Default 1.
  • yDown (boolean) — True for a 2D game whose y grows downward: lift and gravity then point the other way.

FlameFrameOptions

static

Extends: roAssociativeArray

How BGE.ProceduralFrames.flame() draws a flame. Only the colours are required.

Properties

  • startColor (integer) — RGB: each square cools from startColor to endColor as it rises
  • endColor (integer)
  • frameCount (integer) — Default 8
  • frameWidth (integer) — Pixels per frame; default 24 x 48
  • frameHeight (integer)
  • squareCount (integer) — Squares in flight at once; default 6
  • startSize (float) — Pixels, at birth and at the top; default 16 and 5
  • endSize (float)
  • startAlpha (float) — 0-255 at birth, fading out as each square rises; default 250
  • drift (Array.<float>) — Sideways drift of each square, as a fraction of how far it has risen (repeats when there

AnimationFrameDescription

static

Properties

  • startFrame (integer)
  • frameCount (integer)

SpriteAnimation

static

CReate a new SpriteAnimation

Parameters

  • name (string) — Name of the animation
  • frameList (Array.<integer> | AnimationFrameDescription) — Wither an array of cell indexes, or an object {startFrame, frameCount}
  • frameRate (float) — Frames per second the animation should play at. Use BGE.frameRateFor() to play the frames over a set time.
  • playMode (SpritePlayMode, optional, default: "SpritePlayMode.Loop") — Play mode for the sprite: loop, forward, reverse, pingpong

Properties

  • name (string) — Name of the animation
  • frameRate (float) — Frames per second the animation should play at (fractional rates are fine)
  • frameList (Array.<integer>) — Array of the regions of the each cell of this animation
  • playMode (SpritePlayMode) — Play mode for the sprite: loop, forward, reverse, pingpong

Returns

Sprite

static

Extends: AnimatedImage

Parameters

  • owner (GameEntity)
  • spriteSheet (ifDraw2d | Array.<ifDraw2d> | BGE.SpriteFrames) — One sheet, several with the same cell size (cells are numbered across sheets in order), or a BGE.SpriteFrames for packed frames or to share regions with other sprites
  • cellWidth (integer) — Width of each cell in pixels (ignored for a BGE.SpriteFrames)
  • cellHeight (integer) — Height of each cell in pixels (ignored for a BGE.SpriteFrames)
  • args (roAssociativeArray, optional, default: "{}") — Any extra properties to set

Properties

  • spriteSheet (ifDraw2d) — roBitmap to pick cells from (the first sheet, when there are several)
  • spriteSheets (Array.<ifDraw2d>) — Every sheet, in order. Cells are numbered across them: sheet 0's first, then sheet 1's, ...
  • cellWidth (integer) — Width of each animation cell in the sprite image in pixels (0 for packed frames)
  • cellHeight (integer) — Height of each animation cell in the sprite image in pixels (0 for packed frames)
  • spriteFrames (BGE.SpriteFrames) — Which rect of which sheet each frame index draws; may be shared with other sprites
  • animations (roAssociativeArray) — Lookup map of animation name -> SpriteAnimation object
  • activeAnimation (SpriteAnimation) — The current animation being played

Returns

SpriteFrameRect

static

Extends: roAssociativeArray

One frame of a packed sprite sheet (see BGE.SpriteFrames). The rect is where the frame's pixels are on the sheet; the optional offset and source size say where that rect sat in the untrimmed cell, so trimmed frames still line up with each other.

Properties

  • sheet (integer) — Which sheet the frame is on (default 0)
  • x (integer)
  • y (integer)
  • width (integer)
  • height (integer)
  • offsetX (integer) — Position of the rect inside the untrimmed cell (default 0, 0)
  • offsetY (integer)
  • sourceWidth (integer) — Size of the untrimmed cell (default: the rect's own size)
  • sourceHeight (integer)

SpriteFrames

static

The frames of a Sprite: which sheet bitmap and which rect each frame index draws from. Either a uniform grid (every cell cellWidth x cellHeight, numbered row by row, sheet after sheet), or packed frames of any size, each with its own rect, like a texture atlas.

Sprites made from the same SpriteFrames share its roRegions instead of each slicing the sheets again, which matters when many entities use one sheet. Game.getSpriteFrames() caches them by bitmap name, and Game.getSpriteAtlasFrames() gives a packed atlas's (loaded with AssetLoader.loadSpriteAtlas()).

Parameters

  • sheets (ifDraw2d | Array.<ifDraw2d>) — one sheet, or several
  • cellWidth (integer) — grid cell width; ignored when frameRects is given
  • cellHeight (integer) — grid cell height; ignored when frameRects is given
  • frameRects (Array.<BGE.SpriteFrameRect>, optional, default: "invalid") — packed frames, e.g. parsed from a JSON atlas

Properties

  • sheets (Array.<ifDraw2d>) — Every sheet, in order
  • frames (Array.<BGE.SpriteFrameRect>) — Each frame's rect, with every optional field filled in
  • cellWidth (integer) — Grid cell size, or 0 for packed frames
  • cellHeight (integer)

Returns

CharGridArgs

static

Properties

  • cellSize (float) — World units per cell, along x and z
  • origin (BGE.Math.Vector) — The -x/-z corner of cell (0, 0). By default the grid is centred on the world origin.
  • solidKinds (string) — Characters isSolid() counts as solid ("#" by default; "" for none)

CharGridCell

static

One cell of a BGE.CharGrid

Properties

  • col (integer)
  • row (integer)
  • kind (string) — Its character ("" outside the grid)

CharGridGroup

static

A rectangle of cells (a group, a run or a bounding box) found in a BGE.CharGrid

Properties

  • kind (string)
  • col (integer)
  • row (integer)
  • cols (integer)
  • rows (integer)

CharGrid

static

A level written as rows of characters, one per cell: what each character means is up to the game. Finds cells, groups and runs of characters, maps cells to world positions on the ground (x/z), and builds a BGE.SolidWorld from the solid ones. Row 0 is -z, column 0 is -x.

Subclass it to keep a level's own findings (start cell, exits) with the grid, or override isSolid() for solids that aren't a fixed set of characters.

Parameters

Properties

  • colCount (integer)
  • rowCount (integer)
  • cellSize (float)
  • origin (BGE.Math.Vector) — The -x/-z corner of cell (0, 0)
  • solidKinds (string)
  • grid (Array.<Array.<string>>) — Each row's characters, [row][col]; rows shorter than colCount are padded with ""

Returns

SceneChangeInfo

static

Properties

  • scene (GameScene)
  • args (roAssociativeArray)

GarbageCollectionInfo

static

Properties

  • count (integer)
  • orphaned (integer)
  • root (integer)

DebugColors

static

Properties

  • colliders (integer)
  • safe_action_zone (integer)
  • safe_title_zone (integer)

EntityWithId

static

Properties

  • id (dynamic)

PositionXY

static

Properties

  • x (float)
  • y (float)

SizeWH

static

Properties

  • width (float)
  • height (float)

FileLoadTask

static

Extends: LoadTask

Base for the built-in loads. Given a URL, the AssetLoader attaches a download; this task runs it first, then loads the downloaded file. Subclasses override loadFile() (and getFileProgress() if loading takes more than one step) rather than step().

Parameters

  • path (string)

Properties

  • path (string) — The file to load - the download's local file once downloaded
  • source (string) — The path or URL this task was given, for messages
  • download (BGE.DownloadTask) — Downloads path first when it's a URL (invalid for a local file)
  • downloadShare (float) — Share of this task's progress that the download counts for

Returns

BitmapLoadOptions

static

Extends: DownloadOptions

Options for BGE.AssetLoader.loadBitmap().

Properties

  • width (integer) — resize to this width while loading (give height too)
  • height (integer) — resize to this height while loading (give width too)
  • smooth (boolean) — false resizes with nearest neighbour, for crisp pixel art (default true, smooth)
  • drawable (boolean) — true if you'll draw into this bitmap. It's decoded the slower way, in one frame, since

BitmapLoadTask

static

Extends: FileLoadTask

Loads one bitmap. Decodes with the game's TextureLoader, so a large image doesn't stall a frame, falling back to Game.loadBitmapFile() for a drawable bitmap or a file it can't decode.

Parameters

Returns

SoundLoadTask

static

Extends: FileLoadTask

Loads one sound with Game.loadSound().

Parameters

  • game (BGE.Game)
  • soundName (string)
  • path (string)

Returns

FontLoadTask

static

Extends: FileLoadTask

Registers one font file with Game.registerFontFile().

Parameters

Returns

ModelLoadTask

static

Extends: FileLoadTask

Loads a .obj or .stl model a slice at a time: downloads it if it's a URL, reads the file, parses it over as many steps as it needs, downloads any remote textures (a remote .obj's .mtl and every texture it names, or a URL texturePath), then adds it to the game (loading an .obj's textures).

Parameters

Properties

  • loader (BGE.AssetLoader) — Makes this model's texture downloads. Set by AssetLoader.
  • downloadOptions (BGE.DownloadOptions) — Options for this model's texture downloads. Set by AssetLoader.

Returns

SpriteAtlasLoadTask

static

Extends: FileLoadTask

Loads a packed sprite atlas: its .json (downloaded first if it's a URL), then every sheet it lists, decoded side by side like BitmapLoadTasks. Registers the atlas with the game once every sheet has loaded.

Parameters

  • game (BGE.Game)
  • atlasName (string)
  • path (string)

Properties

  • loader (BGE.AssetLoader) — Makes the sheets' downloads. Set by AssetLoader.
  • downloadOptions (BGE.DownloadOptions) — Options for the sheets' downloads. Set by AssetLoader.

Returns

AssetLoader

static

Runs LoadTasks a little at a time, within a per-frame time budget, so long loads don't freeze the game. A scene gets one in GameScene.onLoad(); game.assets is one you can use at any time for background loading.

Once every queued task has finished, onComplete(loader) is called. Adding a task after that starts a new batch: progress and errors start again from scratch.

A built-in load given a http(s):// URL downloads it first, caching it in cachefs: (see download()).

Parameters

Properties

  • onComplete (function) — Called once when the queue drains, with this loader
  • timer (BGE.GameTimer) — Measures each update()'s budget
  • stallWarningSeconds (float) — Seconds a task can wait on a task in another loader, with nothing else to do, before a warning is logged
  • maxConcurrentDownloads (integer) — Most downloads this loader runs at once (each loader, including game.assets, has its own

Returns

DownloadOptions

static

Extends: roAssociativeArray

Options for downloading a URL - see AssetLoader.download() and the built-in loads.

Properties

  • cache (boolean) — false downloads to tmp: for this launch only, instead of the cachefs: cache (default true)
  • refresh (boolean) — true downloads again even when a cached copy exists (default false)
  • timeoutSeconds (integer) — seconds a download may take before it's abandoned (default 30)
  • retries (integer) — how many more times a download is tried after a network/server error or timeout (default 1)
  • extension (string) — the extension to save the file with (e.g. ".jpg"), for a server that sends the wrong type.

DownloadSlots

static

Limits how many downloads run at once. Each AssetLoader has one.

Properties

  • max (integer) — Most downloads at once
  • active (integer) — Downloads running now

DownloadTask

static

Extends: LoadTask

Downloads a URL to a local file. A copy cached by an earlier download (even in an earlier launch) is used without a request. Queue one with AssetLoader.download(); once it's done without an error, localPath is the file.

Parameters

Properties

  • url (string) — The URL being downloaded
  • localPath (string) — The local file, once done
  • fromCache (boolean) — True if the file was already cached, so no request was made
  • elapsedMs (integer) — How long the download took, in milliseconds (0 for a cached file)
  • slots (BGE.DownloadSlots) — Shared with the other downloads in the same loader, to limit how many run at once
  • timer (BGE.GameTimer) — Times each attempt, for the timeout

Returns

LoadTask

static

One unit of work for a BGE.AssetLoader: loading an asset, parsing part of a model, building part of a level. The loader calls step() repeatedly (several times a frame if it's fast, once a frame if it's slow) until it returns true.

Extend this class for your own work, or use AssetLoader.addStep() for a plain function.

Properties

  • name (string) — Shown in log messages
  • weight (float) — This task's share of the loader's overall progress, relative to the other tasks
  • error (dynamic) — Set to a message string if the task failed. A failed task counts as done.
  • done (boolean) — Set by the loader once step() has returned true
  • dependsOn (Array.<LoadTask>) — Tasks that must finish before this one starts - see after()
  • waitingForNextFrame (boolean) — Set true in step() when there's nothing more to do until next frame (e.g. waiting on a
  • progressHighWater (float) — Highest progress reported so far, kept by the loader so the bar never goes backwards
  • queuedIn (string) — Id of the AssetLoader this task was queued in, set by the loader
  • queueNumber (integer) — This task's number in that loader, set by the loader

Returns

LoadingScreen

static

Drawn over the game while a scene is loading (see GameScene.onLoad()). Extend it and override draw() for your own loading screen, then return it from GameScene.getLoadingScreen() or set it as game.loadingScreen.

It's drawn on the UI canvas, above the game UI and the fade overlay, below the debug UI.

Properties

  • showAfterSeconds (float) — Loads that finish sooner than this never show the screen, so fast loads don't flash

DefaultLoadingScreen

static

Extends: LoadingScreen

The engine's default loading screen: black, with a progress bar and a label.

Parameters

  • font (roFont, optional, default: "invalid")

Properties

  • backgroundColor (integer) — Packed RGBA
  • barColor (integer) — Packed RGBA
  • barBackgroundColor (integer) — Packed RGBA
  • label (string) — Text above the bar ("" for none)
  • font (roFont) — Font for the label (no label is drawn without one)

Returns

SceneAsset

static

Extends: roAssociativeArray

An asset a scene owns, freed when the game leaves the scene

Properties

SharedDownloadTask

static

Extends: DownloadTask

A download of a URL that another task in the same AssetLoader is already downloading. It waits for that download and uses its file, rather than requesting the URL again. If that download is aborted, this one downloads the URL itself. Made by AssetLoader.getDownloadTask().

Parameters

Properties

Returns

SpriteAtlas

static

A packed sprite atlas loaded with AssetLoader.loadSpriteAtlas() or Game.loadSpriteAtlas(): its sheets (loaded as bitmaps) and every frame's rect. Game.getSpriteAtlasFrames() turns it into a shared BGE.SpriteFrames.

The .json it's read from is {sheets: ["hero.png", "hero_1.png"], frames: [SpriteFrameRect...]}, as tools/render-character.py --packed writes. Sheet files are relative to the .json.

Properties

  • name (string) — The name it was loaded under
  • source (string) — The .json path or URL it was loaded from
  • sheets (Array.<string>) — The name each sheet's bitmap is loaded under (<name>#0, <name>#1, ...)
  • sheetPaths (Array.<string>) — Each sheet's path or URL
  • frames (Array.<BGE.SpriteFrameRect>) — Every frame, in frame order

StepTask

static

Extends: LoadTask

A LoadTask that calls a plain function once per step - see AssetLoader.addStep().

Parameters

  • stepFunction (function)
  • context (dynamic)
  • oncePerFrame (boolean, optional, default: false)

Returns

TextureResult

static

Extends: roAssociativeArray

The outcome of a texture request: ok with a bitmap, or not ok.

Properties

  • ok (boolean)
  • bitmap (dynamic) — the decoded bitmap, invalid unless ok
  • timedOut (boolean) — true if the texture manager didn't answer within TextureLoader.timeoutMs

TextureLoader

static

Decodes images with one roTextureManager. On a Roku the decode runs off the BrightScript thread, so a large image doesn't stall a frame the way CreateObject("roBitmap", path) does. Bitmaps it makes can't be drawn into before Roku OS 16. The game owns one (game.getTextureLoader()), and BGE.AssetLoader.loadBitmap() uses it.

Properties

  • timeoutMs (integer) — How long a request may take before getResult() gives up on it

Returns

TiledMapLoadTask

static

Extends: FileLoadTask

Loads a Tiled map, its external .tsj tilesets and its images, over as many frames as it takes - see AssetLoader.loadTiledMap().

Parameters

  • game (BGE.Game)
  • mapName (string)
  • path (string)

Properties

  • loader (BGE.AssetLoader) — Makes the tileset and image downloads. Set by AssetLoader.
  • downloadOptions (BGE.DownloadOptions) — Options for those downloads. Set by AssetLoader.

Returns

static

Steers an agent to a target round the walls of a BGE.NavGrid. While the agent can see the target, steer() returns invalid and the game moves it however it likes (straight at it, circling, attacking). Otherwise it follows a path, searched again on a timer.

Sight is checked a few times a second, not every frame. Override checkSight() for another test (e.g. a raycast, or a view cone).

Parameters

Properties

  • nav (BGE.NavGrid)
  • plane (BGE.SeparationPlane) — Options: see BGE.NavFollowerOptions
  • sightInterval (float)
  • repathInterval (float)
  • repathDistance (float)
  • minRepathInterval (float)
  • arriveRadius (float)
  • searchBudgetMs (integer)
  • searchOptions (BGE.NavSearchOptions)
  • pathWhileVisible (boolean)
  • sightSnapRings (integer)
  • canSeeTarget (boolean) — The last line-of-sight result
  • path (Array.<BGE.NavPoint>) — The path being followed, in the grid's coordinates, and the waypoint it's heading for
  • pathIndex (integer)
  • lastSearch (dynamic) — The last search to finish (a BGE.NavPathSearch), and how many steer() calls it took;
  • lastSearchFrames (integer)

Returns

Example

CODE
m.follower = new BGE.NavFollower(nav, {plane: BGE.SeparationPlane.xz, arriveRadius: 0.5})
' each frame:
way = m.follower.steer(m.position, player.position, dt)
if invalid <> way
m.moveBy(way, m.speed * dt)
else if m.follower.canSeeTarget
m.moveToward(player.position, dt)
end if
static

A coarse grid of walkable and blocked cells built from a BGE.SolidWorld, for finding paths around its solids with A*.

Each solid is grown by agentRadius and every cell it overlaps is blocked, so a path that keeps the agent's centre in open cells keeps its body clear of the solids. Paths are smoothed with line-of-sight checks across the cells, so they don't zig-zag along the grid.

The grid works in the SolidWorld's own 2D coordinates. For a top-down game that's world x/y; for a 3D ground plane, store world z as the SolidWorld's y and read each waypoint's y as z.

Parameters

  • world (BGE.SolidWorld) — the solids to path around. The grid keeps it, for rebuild()
  • options (BGE.NavGridOptions, optional, default: "{}") — cellSize (default 32), agentRadius (default 0), and the area to cover (minX, minY, width, height; default: every solid, plus agentRadius and one cell round the outside)

Properties

  • cellSize (float) — Width and height of each cell
  • agentRadius (float) — How far solids are grown before they block cells: the agent's radius
  • minX (float) — Bottom-left corner of the grid
  • minY (float)
  • cols (integer) — Grid size in cells
  • rows (integer)
  • maxPooledSearches (integer) — Finished searches leave their per-cell arrays (about 3 entries per cell) for later searches

Returns

Example

CODE
nav = new BGE.NavGrid(world, {cellSize: 16, agentRadius: 10})
path = nav.findPath(enemy.position.x, enemy.position.y, player.position.x, player.position.y)
' path[0] is the start, path[path.count() - 1] the goal; [] if there's no way there
static

An A* search across a BGE.NavGrid, run a little at a time. Make one with NavGrid.startSearch(), call step(budgetMs) each frame until it returns true, then read status and path.

Moves are 8-way; diagonals can't cut a blocked cell's corner.

Parameters

Properties

  • status (string) — A BGE.NavPathStatus value
  • path (Array.<BGE.NavPoint>) — Waypoints once the search has finished: path[0] is the start, the last is the goal (or the
  • expandedCells (integer) — How many cells the search has expanded so far

Returns

Example

CODE
m.search = m.nav.startSearch(fromX, fromY, toX, toY)
' each frame:
if m.search <> invalid and m.search.step(2)
if m.search.status <> BGE.NavPathStatus.failed
m.waypoints = m.search.path
end if
m.search = invalid
end if
static

A point on a BGE.NavGrid's plane, in its SolidWorld's coordinates.

Properties

  • x (float)
  • y (float) — World y for a top-down game; world z for a 3D ground plane
static

One cell of a BGE.NavGrid.

Properties

  • col (integer)
  • row (integer)
static

Extends: roAssociativeArray

Options for new BGE.NavGrid().

Properties

  • cellSize (float) — Width and height of each cell. Smaller finds narrower gaps but costs more memory and
  • agentRadius (float) — Solids are grown by this much before they block cells, so paths keep the agent's body clear
  • minX (float) — Bottom-left corner of the area the grid covers. Default 0 (only used with width/height).
  • minY (float)
  • width (float) — Size of the area the grid covers. Give both, or the grid covers every solid in the world
  • height (float)
static

Extends: roAssociativeArray

Options for BGE.NavGrid.findPath() and startSearch().

Properties

  • maxExpandedCells (integer) — Give up after expanding this many cells. Default 20000.
  • allowPartial (boolean) — When the goal can't be reached (or the search gives up), return a path to the cell
  • smooth (boolean) — Smooth the path with line-of-sight checks. Default true.
  • snapRings (integer) — A start or goal in a blocked cell moves to the nearest open cell up to this many cells
static

Extends: roAssociativeArray

Options for new BGE.NavFollower(). Each is also a public field you can change later.

Properties

  • plane (BGE.SeparationPlane) — Which two position axes are the grid's x and y: xz (default, the ground in a 3D game)
  • sightInterval (float) — Seconds between line-of-sight checks. Default 0.25.
  • repathInterval (float) — Seconds between path searches while the target is out of sight. Default 0.5.
  • repathDistance (float) — Search again early once the target is this far from where the last search aimed, but
  • minRepathInterval (float) — Default 0.25.
  • arriveRadius (float) — A waypoint is reached within this distance. Default half the grid's cell size.
  • searchBudgetMs (integer) — Milliseconds of search per steer(): a long search runs over several frames. Default 0:
  • searchOptions (BGE.NavSearchOptions) — Passed to every search
  • pathWhileVisible (boolean) — Keep searching on the timer while the target is in sight, so a path is ready the moment
  • sightSnapRings (integer) — How far hasLineOfSight() moves an end out of a blocked cell. Default 2.
static

For internal use: one search's per-cell state, kept by the grid and reused by later searches. Indexes are into the grid's padded cell array.

Properties

  • gCost (Array.<float>)
  • parentOf (Array.<integer>)
  • mark (Array.<integer>) — A cell is open in this search when its mark is stamp, closed when it's stamp + 1
  • stamp (integer)
  • heapCells (Array.<integer>)
  • heapF (Array.<float>)

AdaptiveQualityOptions

static

Extends: roAssociativeArray

Options for Game.enableAdaptiveQuality(). Every field is optional.

Properties

  • targetFps (float) — Frame rate to hold (default 20)
  • minLevel (integer) — Lowest level the controller may choose (default basic)
  • maxLevel (integer) — Highest level the controller may choose (default ultra)
  • windowSeconds (float) — Seconds of frames averaged (default 1.0)
  • outlierFrameSeconds (float) — Frames longer than this are left out of the average, e.g. garbage collection (default 0.25)
  • hitchFrameMultiple (float) — A frame longer than this many target frames is a hitch (default 2.5)
  • hitchesToStepDown (integer) — Step down when this many hitches happen within hitchWindowSeconds, whatever the
  • hitchWindowSeconds (float) — (default 2.0)
  • settleSeconds (float) — Seconds ignored after a level or scene change (default 0.25)
  • stepDownBelowFraction (float) — Step down when average fps < targetFps * this (default 0.9)
  • stepUpHeadroomFraction (float) — Step up when average fps >= targetFps * this... (default 1.25)
  • stepUpSustainSeconds (float) — ...for this many seconds (default 0.5)
  • maxMeasurableFps (float) — Display refresh ceiling for the step-up threshold (default 60)
  • stepDownCooldownSeconds (float) — Minimum seconds between two downward steps (default 0.75)
  • probeFailWindowSeconds (float) — A step down this soon after a step up marks that level as failed (default 1.5)
  • probeBackoffSeconds (float) — Seconds a failed level isn't retried; doubles on each repeat failure, up to 4x, and
  • stillProbeBackoffSeconds (float) — Like probeBackoffSeconds, while the camera is still (default 1)
  • stepUpJumpFraction (float) — Step up two levels at once when average fps >= targetFps * this; 0 disables (default 2.0)
  • stillCameraSeconds (float) — Seconds the camera must stay still before quality climbs faster; 0 disables (default 0.2)
  • stillSettleSeconds (float) — Seconds ignored after a level change while the camera is still (default 0.1)
  • stillSampleSeconds (float) — Seconds of frames a still camera needs before stepping up (default 0.2)
  • cameraMoveMaxStepDown (integer) — Most levels the camera starting to move from still may drop the level, before the usual

SceneQualityOptions

static

Extends: roAssociativeArray

A scene's own render quality settings (GameScene.qualityOptions), in force while it's the current scene. Every field is optional; leave one out to use the game's.

Properties

  • targetFps (float) — Frame rate to hold in this scene, instead of enableAdaptiveQuality()'s
  • minLevel (integer) — Lowest level adaptive quality may choose in this scene
  • maxLevel (integer) — Highest level adaptive quality may choose in this scene
  • fixedDrawDistance (boolean) — Draw out to the camera's maxDrawDistance at every level, so the view never reaches

QualityController

static

Chooses a render quality level from measured frame times. Game runs one for you after enableAdaptiveQuality(); you don't normally create one yourself.

Parameters

Properties

  • targetFps (float)
  • minLevel (integer)
  • maxLevel (integer)
  • windowSeconds (float)
  • outlierFrameSeconds (float)
  • hitchFrameMultiple (float)
  • hitchesToStepDown (integer)
  • hitchWindowSeconds (float)
  • settleSeconds (float)
  • stepDownBelowFraction (float)
  • stepUpHeadroomFraction (float)
  • stepUpSustainSeconds (float)
  • maxMeasurableFps (float)
  • stepDownCooldownSeconds (float)
  • probeFailWindowSeconds (float)
  • probeBackoffSeconds (float)
  • stillProbeBackoffSeconds (float)
  • stepUpJumpFraction (float)
  • stillCameraSeconds (float)
  • stillSettleSeconds (float)
  • stillSampleSeconds (float)
  • cameraMoveMaxStepDown (integer)

Returns

RenderQualityManager

static

Owns the game's current render quality level. Reach it through game.renderQuality; most games only need Game.setQualityLevel() or Game.enableAdaptiveQuality().

Parameters

  • renderer (BGE.Renderer) — the renderer to apply settings to (the game canvas)
  • initialLevel (integer) — a BGE.RenderQualityLevel value

Returns

RenderQualitySettings

static

Extends: roAssociativeArray

Every draw-quality value a BGE.Renderer uses. Each BGE.RenderQualityLevel has a preset (see BGE.getRenderQualityPreset()); override individual fields per level with game.renderQuality.overridePreset().

Adding a new quality setting: add the field here, give it a value at every level in RenderQualityPresets.bs, and read it via renderer.qualitySettings.

Properties

  • drawDistanceScale (float) — Multiplier on Camera3d.maxDrawDistance
  • drawDistanceOverride (float) — Absolute draw distance for this level; 0 or less means "use drawDistanceScale"
  • planeSliceCount (integer) — Horizontal slices used to draw a DrawablePlane in perspective
  • triangleSkipSize (float) — Triangles smaller than this many pixels on both axes are skipped
  • triangleQuickDrawStep (integer) — Band thickness, in pixels, of the coarse fill a moving triangle may use (1 = never
  • fastDrawParallelogramTolerance (float) — How far from a true parallelogram a billboard's quad may be and still use the
  • fastDrawPerpendicularityTolerance (float) — How far from perpendicular a billboard's quad edges may be and still use the
  • billboardReuseError (float) — How far a billboard's (rectangle, image, polygon, ...) reused rendering may be off
  • billboardReuseMaxAngleDegrees (float) — How far, in degrees, the direction a billboard is seen from may turn before its
  • modelImpostorError (float) — How far a reused model rendering (DrawableModel.useImpostor) may be off, as a
  • modelImpostorMaxDepthRatio (float) — How far a model may reach in depth, as a multiple of how far its nearest point is,
  • modelImpostorBlitMaxDepthRatio (float) — The same, for the single scaled blit of a reused model rendering: a model deeper than
  • modelImpostorMaxSizeChange (float) — How much a reused model rendering may grow or shrink on screen (a ratio, either way)
  • modelImpostorMaxAngleDegrees (float) — How far, in degrees, the direction a model is seen from may turn before its reused
  • modelImpostorStripMaxAngleDegrees (float) — How far, in degrees, the direction a model is seen from may turn and still redraw its
  • modelImpostorStripErrorScale (float) — How much further off than modelImpostorError strips may be before a redraw
  • modelImpostorStripMaxErrorPixels (float) — The most, in pixels, strips may put any visible vertex from where it really is, however
  • modelImpostorMaxLightChange (float) — How much any light reaching a model may brighten or dim (a 0-1 fraction of full
  • planeLightPoolMaxDriftPixels (float) — How far, in pixels of a plane's top-down bitmap, a point light's pool on a shaded
  • planeLightPoolMaxLightChange (float) — How much a pool's color may change (a 0-1 fraction of full brightness, per channel)
  • wallStripWidth (integer) — Screen pixels between wall strips (BGE.DrawableWalls) at the horizon
  • wallLodDistanceFraction (float) — Walls (BGE.DrawableWalls) further than this fraction of the draw distance draw one strip
  • quadColumnsPerTexel (float) — Most texture columns a quad drawn as columns (BGE.QuadColumnDrawer) gets, per texel
  • quadMinPixelsPerColumn (float) — Fewest screen pixels each such column covers: a quad gets no more columns than
  • quadMaxAffineErrorPixels (float) — How far, in pixels, a column's texture may sit from where perspective puts it: a quad
  • fogSilhouetteBand (float) — Most pixels each stair of a fog silhouette's outline steps, down or across (see
  • voxelColumns (integer) — Screen columns a DrawableVoxelTerrain marches (its cost is about columns x depth steps)
  • voxelBandSteps (integer) — Depth steps a DrawableVoxelTerrain takes before its step doubles
  • animationLodDistanceScale (float) — Scales every oriented sprite's lodDistance (BGE.DrawableOrientedSprite), how far out its

RenderQualitySettingsOverrides

static

Extends: roAssociativeArray

Any subset of BGE.RenderQualitySettings, for game.renderQuality.overridePreset().

Properties

  • drawDistanceScale (float)
  • drawDistanceOverride (float)
  • planeSliceCount (integer)
  • triangleSkipSize (float)
  • triangleQuickDrawStep (integer)
  • fogSilhouetteBand (float)
  • voxelColumns (integer)
  • voxelBandSteps (integer)
  • fastDrawParallelogramTolerance (float)
  • fastDrawPerpendicularityTolerance (float)
  • billboardReuseError (float)
  • billboardReuseMaxAngleDegrees (float)
  • modelImpostorError (float)
  • modelImpostorMaxDepthRatio (float)
  • modelImpostorBlitMaxDepthRatio (float)
  • modelImpostorMaxSizeChange (float)
  • modelImpostorMaxAngleDegrees (float)
  • modelImpostorStripMaxAngleDegrees (float)
  • modelImpostorStripErrorScale (float)
  • modelImpostorStripMaxErrorPixels (float)
  • modelImpostorMaxLightChange (float)
  • planeLightPoolMaxDriftPixels (float)
  • planeLightPoolMaxLightChange (float)
  • wallStripWidth (integer)
  • wallLodDistanceFraction (float)
  • quadColumnsPerTexel (float)
  • quadMinPixelsPerColumn (float)
  • quadMaxAffineErrorPixels (float)
  • animationLodDistanceScale (float)

Fog

static

Distance fog for a Camera3d (its fog), sharing the draw distance's fade band (Camera3d.drawDistanceFadeFraction). Off by default.

With a backdropHeight, the band of the screen from where the ground ends up to that height at the draw distance (or the horizon, if lower) is filled in color behind everything, so objects fading out fade into fog rather than the sky. Drawables with castsFogSilhouette set keep blocking the sky past the draw distance, in color, out to silhouetteReach times it: a model by its own outline (a pointed roof stays pointed, see silhouetteHulls), an image by its corners, level walls (BGE.DrawableWalls) as their real outline.

Fog fixes the draw distance: it doesn't change with the render quality level (see followsQuality).

Fields are read every frame, so they can be changed live.

Properties

  • enabled (boolean) — Nothing is drawn or worked out while this is false
  • color (integer) — RGB (0xRRGGBB), like Drawable.color
  • backdropHeight (float) — How high the backdrop reaches at the draw distance, in world units (0 for no backdrop). It
  • backdropRegion (dynamic) — An roRegion stretched over the backdrop, tinted with color (so draw it white), or
  • silhouetteHulls (boolean) — Outline each silhouette by its model's own points, split up its height (a tower on a nave,
  • silhouetteReach (float) — Silhouettes reach this many times the draw distance (0 for none). 1 keeps the fog that
  • silhouetteStartAlpha (float) — Fog makes up the opacity a fading object has lost, once its fade alpha drops below this
  • silhouetteOpacityLead (float) — How much faster a fading object's silhouette makes up the opacity it has lost: drawn at
  • followsQuality (boolean) — With fog on, the draw distance stays at Camera3d.maxDrawDistance at every render quality
  • qualityTransitionSeconds (float) — Seconds a draw distance change takes to ease in while followsQuality is set, when longer

Example

CODE
camera.fog.enabled = true
camera.fog.color = &h1C2842
camera.fog.backdropHeight = 400
houseModel.castsFogSilhouette = true

RendererResourceSize

staticreadonly

Default: 400

DEPTH_TIE_EPSILON

staticreadonly

Default: 0.5

TRIANGLE_SPAN_MAX_BANDS

staticreadonly

Most bands a triangle is filled with before the two-call exact fill is cheaper. On a Roku Ultra (rendererTest's "Polygon Fill Benchmark", #539) a band cost ~14 us, the exact fill ~0.35-0.45 ms. A cost break-even rather than a quality knob, so it isn't in RenderQualitySettings - the quality trade is the band size while moving, triangleQuickDrawStep.

Default: 24

POLYGON_SPAN_BANDS_PER_TRIANGLE

staticreadonly

Most bands per triangle of its fan a convex polygon is filled with (one DrawRect per run of equal bands) before its triangles are cheaper. On a Roku Ultra (rendererTest's "Polygon Fill Benchmark", #539) a band cost ~11 us and a triangle's exact fill ~0.4 ms.

Default: 28

CONCAVE_SPAN_QUICK_MAX_BANDS

staticreadonly

Most 1px bands a moving concave polygon is filled with before it uses the quick-draw band step (triangleQuickDrawStep). A concave fill has no cheaper exact fallback, and on a Roku Express a scanline band cost ~45-60 us (rendererTest "Polygon Fill Benchmark", #547), so this caps a moving one at ~2-3 ms of 1px bands there.

Default: 48

TriangleQuickDrawParams

static

The triangle fill values a Renderer is using - see getTriangleQuickDrawParams().

Properties

  • skipSize (float) — While moving, triangles smaller than this many pixels on both axes are skipped
  • maxBands (integer) — A triangle whose shorter bounding-box side, divided by the band size, is at most this
  • step (integer) — Band size, in pixels, of the coarse fill used while moving

LevelOfDetailOptions

static

Properties

  • levelOffset (integer)
  • levelOfDetail (integer)

RendererOptions

static

Properties

  • useBitmapPooling (boolean)

Renderer

static

Wrapper for Draw2D calls, so that we can keep track of how much is being drawn per frame

Parameters

  • draw2d (ifDraw2d)
  • mainGame (BGE.Game, optional, default: "invalid")
  • cam (BGE.Camera, optional, default: "invalid")
  • options (RendererOptions, optional, default: "{useBitmapPooling: true}")

Properties

  • minimumFrameRateTarget (integer) — Frame rate target - the game will reduce quality if this target is not met
  • onlyDrawWhenInFrame (boolean)
  • drawDebugCells (boolean)
  • drawDebugTrianglePoints (boolean)
  • computeOverlapClusters (boolean) — Whether render() computes overlap clusters (BGE.DepthSort.groupIntoClusters)
  • occlusionCullingEnabled (boolean) — Whether static drawables flagged isOccluder hide what's behind them.
  • occlusionBandCount (integer) — Number of vertical bands in the occlusion span map.
  • maxOccluders (integer) — The most occluders considered per frame.
  • occlusionMargin (float) — Pixels added around each tested object's canvas box (plus its outline width) before
  • showOcclusionDebug (boolean) — Whether to draw the occlusion debug overlay (see Game.debugDrawOcclusion()).
  • occluderDrawPolicy (BGE.OccluderDrawPolicy) — How occluders trade exactness for speed - see BGE.OccluderDrawPolicy. Takes effect
  • profileStages (boolean) — When true, render() times each of its stages, and each scene object type's draws -
  • fogSilhouettesDrawnLastFrame (integer) — Fog silhouettes (see BGE.Fog) drawn and worked out last frame; 0 worked out means the last
  • fogSilhouettesProjectedLastFrame (integer)
  • camera (Camera)
  • quadColumns (dynamic) — Draws textured quads as projected texture columns (see drawTexturedQuadTo())
  • maxQuadColumnTextures (integer) — Most textures getQuadColumnTexture() keeps before starting over (each holds its bitmap)
  • frameCount (integer)
  • bmpPool (BGE.ScratchBitmapPool)
  • qualitySettings (BGE.RenderQualitySettings) — The draw-quality values this renderer uses. Game sets these from the current
  • fixedDrawDistance (boolean) — Draw out to the camera's maxDrawDistance at every quality level (see BGE.SceneQualityOptions).
  • projectedPointCount (integer) — For tests: points projected by paths that don't call worldPointToCanvasPoint()
  • qualityVersion (integer) — Bumped by every setQualitySettings() call, so scene objects know to redraw their
  • lights (Array.<BGE.Light>) — The lights shading this renderer's isShaded drawables - see addLight(). With no
  • lightingVersion (integer) — Bumped whenever a light is added, removed or changed, so scene objects know to
  • game (BGE.Game)
  • name (string)
  • statsString (string)
  • resources
  • dummyScreen (roScreen)

Returns

ScanlinePolygonFill

static

Fills any polygon, concave or self-intersecting, as DrawRect bands: a scanline fill with an active-edge list. Spans in a band never overlap, so translucent fills blend once. Use it through Renderer.drawPolygonAsSpansTo()/drawConcavePolygonTo().

ScratchBitmap

static

Parameters

  • id (string)
  • w (integer)
  • h (integer)

Properties

  • bitmap (roBitmap)
  • id (string)

Returns

ScratchRegion

static

Parameters

Properties

Returns

ScratchBitmapPool

static

initialCount < 0 uses the device tier's default (see setUpBasedOnDevice())

Parameters

  • doPooling (boolean, optional, default: true)
  • initialCount (integer, optional, default: -1)
  • forcePoolingRegardlessOfDevice (boolean, optional, default: false)

Returns

CAMERA_MIN_ZOOM

staticreadonly

The smallest and largest zoom Camera.getEffectiveZoom() allows

Default: 0.1

CAMERA_MAX_ZOOM

staticreadonly

Default: 100

MAX_ZOOM_STEP_SECONDS

staticreadonly

Longest frame step zoomTo() advances by, so one slow frame can't finish a zoom in a jump.

Default: 0.1

Camera

static

Properties

  • orientation (dynamic) — A vector pointed in the direction of the camera
  • position (BGE.Math.Vector)
  • sortsByGroundDistance (boolean) — Sort whole objects by how far ahead they are across the ground (groundDistanceAhead()),
  • motionChecker (MotionChecker)
  • frameSize (BGE.Math.Vector)
  • projectionVersion (integer) — Bumped whenever something about the camera's projection - as opposed to its
  • zoom (float) — How much bigger the view is drawn, about its middle: 1 as it comes, 2 twice as big, 0.5
  • drawDistanceScale (float) — Multiplier on a 3D camera's maxDrawDistance, set from the renderer's quality
  • drawDistanceOverride (float) — Absolute draw distance from the renderer's quality settings; 0 or less means
  • planeDrawDistanceScale (float) — How far a 3D camera's ground plane reaches, as a multiple of maxDrawDistance - the
  • planeDrawDistanceOverride (float) — The largest absolute draw distance any quality level uses (0 = none). Set by the
  • worldToCamera (Array.<Array.<float>>)
  • name (string)

Returns

Camera2d

static

Extends: Camera

Properties

  • top (float)
  • bottom (float)
  • right (float)
  • left (float)
  • near (float)
  • far (float)
  • name (string)

PROJECTED_BEHIND_CAMERA_DEPTH

staticreadonly

The depth projectPointsWithDepth() gives a point behind the camera when asked to mark them. Every point in front has a positive depth.

Default: -1

CameraFrustumNormals

static

Properties

  • top (BGE.Math.Vector)
  • bottom (BGE.Math.Vector)
  • left (BGE.Math.Vector)
  • right (BGE.Math.Vector)
  • near (BGE.Math.Vector)

CameraFrustumRays

static

Properties

  • topLeft (BGE.Math.Ray)
  • topRight (BGE.Math.Ray)
  • bottomLeft (BGE.Math.Ray)
  • bottomRight (BGE.Math.Ray)

SHEAR_PITCH_MAX_TAN

staticreadonly

tan(60 degrees): the steepest pitch a shear camera shows

Default: 1.7320508

MAX_DRAW_DISTANCE_TRANSITION_STEP_SECONDS

staticreadonly

Longest frame step the draw-distance transition advances by, so one slow frame can't finish a transition in a single jump.

Default: 0.1

Camera3d

static

Extends: Camera

Properties

  • fieldOfViewDegrees (float) — The horizontal field of view at zoom 1. The one in use is getEffectiveFieldOfViewDegrees().
  • rollDegrees (float) — Rotation about the camera's own forward/view axis, in degrees. Positive = right
  • pitchMode (string) — BGE.CameraPitchMode: how the pitch in orientation is shown. With "shear", the view
  • maxDrawDistance (float) — How far (world units) in front of the camera your game wants to draw. The
  • drawDistanceFadeFraction (float) — The far end of the draw distance over which objects fade out instead of popping
  • fog (BGE.Fog) — Distance fog (see BGE.Fog). Off by default.
  • drawDistanceTransitionSeconds (float) — Seconds a change in draw distance (a quality level change, or a new
  • fadeDistanceScaleLimit (float) — The most a Drawable.fadeDistanceScale counts for (0: no limit). The Renderer sets it each
  • frustumNormals (CameraFrustumNormals)
  • frustrumConvergence (BGE.Math.Vector)
  • hasLevelForward (boolean) — the forward direction levelled onto the ground (unit x and z), unless looking straight
  • levelForwardX (float)
  • levelForwardZ (float)
  • frustumRays (CameraFrustumRays)
  • name (string)

CameraBoom

static

Keeps a chase camera out of walls: given the point the camera looks at and where it would like to be, update() returns the closest position on that line that no collider blocks. It pulls in at once when something comes between them, and eases back out when it clears.

Obstacles need 3D colliders (BoxCollider3d/SphereCollider3d): a static building is an isStatic entity with a BoxCollider3d. Give them their own memberFlags bit and set collidableFlags to it, so the player's and enemies' own colliders don't pull the camera in.

m.boom = new BGE.CameraBoom(m.game, {collidableFlags: CAMERA_BLOCKER}) camera.position = m.boom.update(lookAt, wantedPosition, dt)

Parameters

  • game (BGE.Game)
  • args (roAssociativeArray, optional, default: "{}")

Properties

  • probeRadius (float) — Thickness of the camera: rays are cast round a circle this wide, and the camera stops
  • minDistance (float) — Never closer to the look-at point than this, even if blocked closer still
  • collidableFlags (integer) — Colliders whose memberFlags overlap this block the camera
  • easeOutRate (float) — How quickly the camera eases back out, 1/seconds (higher is faster)
  • closeDistance (float) — isClose() is true within this distance, e.g. to fade out the player
  • game (BGE.Game)
  • distance (float)
  • blocked (boolean)

Returns

ChaseCameraOptions

static

Extends: roAssociativeArray

Settings for BGE.ChaseCamera; any left out keep the class defaults.

Properties

  • distance (float)
  • height (float)
  • lookDown (float)
  • followRate (float)
  • rollRate (float)
  • pitchFollow (float)
  • maxPitch (float)
  • rollFollow (float)
  • terrain (BGE.DrawableVoxelTerrain)
  • groundClearance (float)
  • heading (float)

ChaseCamera

static

A chase camera for vehicles that pitch and roll (planes, spaceships, boats): it sits behind a target entity along its heading and pitch, eased so turns swing the view round rather than snapping it, and rolls with the target's bank. Unlike BGE.OrbitCamera there's no look input: the target's own attitude, passed to update() each frame, steers it.

It's a BGE.FollowCamera, so a scene can swap it for another rig (e.g. a BGE.OrbitCamera). Give it a terrain to keep the camera above the ground. Call update() after everything has moved, e.g. in the scene's onPostUpdate():

m.chase = new BGE.ChaseCamera(camera, plane, {heading: plane.heading, terrain: m.terrain}) m.chase.update(dt, plane.heading, plane.pitch, plane.bank)

Parameters

Properties

  • camera (BGE.Camera3d)
  • target (BGE.GameEntity)
  • distance (float) — Distance behind the target, in world units, measured along the camera's eased heading and
  • height (float) — Raised this far above that point, straight up in world space
  • lookDown (float) — Radians the camera looks below its own pitch, so the target sits low with more to see ahead
  • followRate (float) — How quickly heading and pitch catch up with the target, 1/seconds (higher is tighter)
  • rollRate (float) — How quickly the roll catches up with the target's bank, 1/seconds
  • pitchFollow (float) — Fraction of the target's pitch the camera takes up
  • maxPitch (float) — The camera's pitch is kept within +/- this, radians
  • rollFollow (float) — Fraction of the target's bank the camera rolls by; under 1 keeps the target looking banked
  • terrain (BGE.DrawableVoxelTerrain) — Optional: the camera stays groundClearance above it
  • groundClearance (float)
  • heading (float) — The eased attitude the camera is following: heading (0 faces -z, clockwise seen from above),
  • pitch (float)
  • roll (float)

Returns

FollowCameraInput

static

Extends: roAssociativeArray

What a game passes to FollowCamera.follow() each frame. Each camera reads only the fields it uses, so one input can drive whichever camera is active.

Properties

  • look (BGE.Math.Vector) — BGE.OrbitCamera: x orbits, y tilts, each -1..1 (e.g. the right stick)
  • heading (float) — BGE.ChaseCamera: the target's heading, radians (defaults to its rotation.y, read as a
  • pitch (float) — BGE.ChaseCamera: the target's pitch, radians, positive nose up
  • bank (float) — BGE.ChaseCamera: the target's bank, radians

FollowCamera

static

A camera rig that moves a Camera3d to follow a target entity: BGE.OrbitCamera and BGE.ChaseCamera. Type a field as this to swap rigs without changing the scene's code:

m.rig = new BGE.ChaseCamera(camera, m.player, {heading: m.rig.heading}) m.rig.follow(dt, {look: look, heading: heading, pitch: pitch, bank: bank})

Properties

  • camera (BGE.Camera3d)
  • target (BGE.GameEntity)
  • heading (float) — Ground heading the camera looks along (0 faces -z, increasing turns clockwise seen from above)

GridWallsCameraBoom

static

Extends: BGE.CameraBoom

A camera boom for grid walls (BGE.GridWallsMap): it pulls in by marching through the grid toward the camera, rather than raycasting colliders, so the walls need no colliders and cost no per-frame collision checks.

map = new BGE.GridWallsMap(rows, {cellSize: 192, wallHeight: 128, origin: corner, solid: {"#": "stone"}}) boom = new BGE.GridWallsCameraBoom(m.game, map, {probeRadius: 10, minDistance: 25})

Override isBlockedAt() to block on something besides the map's solid cells.

Parameters

  • game (BGE.Game)
  • map (BGE.GridWallsMap) — the walls that block the camera
  • args (roAssociativeArray, optional, default: "{}") — CameraBoom's fields, and stepLength

Properties

  • stepLength (float) — How far apart (world units) the march samples the line to the camera. Keep it well under
  • map (BGE.GridWallsMap)

Returns

OrbitCameraOptions

static

Extends: roAssociativeArray

Settings for BGE.OrbitCamera; any left out keep the class defaults.

Properties

  • distance (float)
  • height (float)
  • lookHeight (float)
  • minHeight (float)
  • orbitSpeed (float)
  • recenterSpeed (float)
  • lockTurnSpeed (float)
  • lockTilt (float)
  • lockDeadZone (float)
  • lockEase (float)
  • tiltSpeed (float)
  • minTilt (float)
  • maxTilt (float)
  • heading (float)
  • boom (BGE.CameraBoom)

OrbitCamera

static

A third-person chase camera: it sits behind and above a target entity, looking at a point above the target's feet, and swings round that point on a sphere. A look vector (e.g. a right stick) orbits it (x) and tilts it (y); recenter() swings it back behind the target. It never drifts behind a moving target on its own, so camera-relative movement (see BGE.Math.cameraRelativeMove()) runs straight instead of curving. lockOn() turns it to keep a second entity (e.g. an enemy) in view beyond the target.

It's a BGE.FollowCamera, so a scene can swap it for another rig (e.g. a BGE.ChaseCamera). Give it a BGE.CameraBoom to pull it in front of walls between it and the target. Call update() after everything has moved, e.g. in the scene's onPostUpdate():

m.orbit = new BGE.OrbitCamera(camera, player, { boom: new BGE.CameraBoom(m.game, {collidableFlags: CAMERA_BLOCKER}) }) m.orbit.update(dt, m.game.controls.getRawAxis("look"))

Parameters

Properties

  • camera (BGE.Camera3d)
  • target (BGE.GameEntity)
  • heading (float) — Ground heading the camera looks along (heading 0 faces -z)
  • distance (float) — Horizontal distance behind the target at rest, in world units
  • height (float) — Height of the camera above the target's position at rest
  • lookHeight (float) — Height above the target's position of the point the camera looks at
  • minHeight (float) — The camera never goes lower than this above the target's position
  • orbitSpeed (float) — Radians/sec at full look
  • recenterSpeed (float) — Radians/sec while recentering (tilt eases back at a quarter of this)
  • tilt (float) — Tilt added to the resting angle, in radians; positive looks further down on the target
  • tiltSpeed (float) — Radians/sec at full look
  • minTilt (float)
  • maxTilt (float)
  • boom (BGE.CameraBoom) — Optional: pulls the camera in front of blockers
  • lockTurnSpeed (float) — Radians/sec while turning to keep a locked-on entity in view
  • lockTilt (float) — Tilt while locked on, e.g. positive to look down on the ground between the target and the
  • lockTarget (BGE.GameEntity) — The entity the camera keeps in view beyond the target, or invalid; see lockOn()
  • lockDeadZone (float) — Locked on, the camera doesn't turn while the entity is in the middle lockDeadZone of the
  • lockEase (float) — Locked on, an exponential ease: each frame the camera turns 1 - e^(-lockEase * dt) of the
  • recentering (boolean)
  • noLook (dynamic) — follow()'s look when the input has none; update() only reads it
  • lockRefocusing (boolean) — Turning back toward a lockOn() entity that left the dead zone

Returns

GridWallsMapArgs

static

Properties

  • cellSize (float)
  • wallHeight (float)
  • origin (BGE.Math.Vector) — The -x/-z corner of cell (0, 0); origin.y is the floor height.
  • solid (roAssociativeArray) — Map character -> texture name. Any other character is open. roAssociativeArray keys are
  • outsideTexture (string)

GridWallsCell

static

Properties

  • col (integer)
  • row (integer)

GridWallsMap

static

A rectangular grid of solid and open cells. Row 0 is -z, column 0 is -x.

Parameters

Properties

  • colCount (integer)
  • rowCount (integer)
  • cellSize (float)
  • wallHeight (float)
  • origin (BGE.Math.Vector)
  • solidFlags (Array.<dynamic>) — Per-cell lookups, indexed row * colCount + col (read directly by the ray caster).
  • textures (Array.<dynamic>)
  • outsideTexture (string)

Returns

Light

static

A light that shades isShaded drawables. Add it to a renderer with Game.addLight() (or Renderer.addLight()).

Fields can be changed at any time, including mid-game - the renderer notices and redraws whatever the light touches. Use DirectionalLight, PointLight or AmbientLight rather than this class directly.

Parameters

  • lightType (LightType)
  • color (integer)
  • intensity (float)

Properties

  • id (string) — Set by the renderer when the light is added
  • type (LightType)
  • color (integer) — RGB color (0xRRGGBB, as BGE.ColorsRGB)
  • intensity (float) — Multiplier on color. A surface's total light is capped at full brightness, so
  • enabled (boolean) — A disabled light is ignored, as if it had been removed

Returns

DirectionalLight

static

Extends: Light

A light shining in one direction from infinitely far away. Every surface facing against direction is lit equally, however far away it is.

Parameters

  • direction (BGE.Math.Vector) — the direction the light travels in
  • color (integer, optional, default: "BGE.ColorsRGB.White") — RGB color
  • intensity (float, optional, default: "1.0")

Properties

  • direction (BGE.Math.Vector) — The direction the light travels in (needn't be normalized). World space has +y up,

Returns

PointLight

static

Extends: Light

A light shining outward from position, optionally fading out with distance.

Parameters

  • position (BGE.Math.Vector)
  • range (float, optional, default: 0) — how far the light reaches; 0 for no falloff
  • color (integer, optional, default: "BGE.ColorsRGB.White") — RGB color
  • intensity (float, optional, default: "1.0")

Properties

  • position (BGE.Math.Vector)
  • range (float) — How far the light reaches: it fades linearly from full strength at position to

Returns

AmbientLight

static

Extends: Light

Light that reaches every surface equally, whichever way it faces - use it to keep the unlit sides of objects from going too dark, or to tint a whole scene.

Parameters

  • color (integer, optional, default: "BGE.ColorsRGB.White") — RGB color
  • intensity (float, optional, default: 0.25)

Returns

OcclusionSpanMap

static

Per horizontal band of the canvas, the merged x ranges that occluders cover across the whole band, each with the farthest depth of the occluders merged into it (conservative). An object is hidden only if one merged range covers it in every band it touches.

Parameters

  • width (float) — canvas width in pixels
  • height (float) — canvas height in pixels
  • bandCount (integer) — number of horizontal bands the canvas is divided into

Returns

OccluderPolygon

static

Extends: roAssociativeArray

A convex canvas-space polygon that is guaranteed to hide whatever lies behind it.

Properties

  • xs (Array.<float>) — Canvas-space vertices, either winding, 3 or more points.
  • ys (Array.<float>)
  • depth (float) — The farthest vertex's distanceFromCameraFront.
  • area (float) — Projected area, used to keep the largest occluders when capping their number.

CanvasPolygon

static

Extends: roAssociativeArray

A canvas-space polygon, its vertices in order around it.

Properties

  • xs (Array.<float>)
  • ys (Array.<float>)

OcclusionTestBounds

static

Extends: roAssociativeArray

A canvas-space box an object was tested against the occlusion map with.

Properties

  • minX (float)
  • minY (float)
  • maxX (float)
  • maxY (float)

OccluderPanel

static

Extends: roAssociativeArray

A convex, opaque face of a model, in model-local space.

Properties

  • vertices (Array.<BGE.Math.Vector>) — Ordered around the perimeter.
  • normal (BGE.Math.Vector)
  • hasInnerVertices (boolean) — Whether a source triangle has a corner inside the panel rather than on its edge.

QuadColumnDrawer

static

Draws a perspective-textured quad as projected texture columns: one DrawTransformedObject per 1-texel column, perspective correct, with no scratch bitmaps. Textured triangles (model faces) draw the same way with drawTriangleTo().

Corners are given in camera space and projected once; column ends are lerped in camera space then divided (or, with an orthographic projection, just scaled). Columns run along whichever texture axis changes depth least, so each is near constant depth. How many is set by render quality (quadColumnsPerTexel, quadMinPixelsPerColumn), and a per-frame budget keeps a bitmap under Roku's limit on queued draws. Call beginFrame() once per frame (Renderer.render() does).

Properties

  • maxColumnsPerFrame (integer) — Most columns drawn per frame, across every quad (Roku drops all draws into a bitmap
  • nearZ (float) — Camera-space z a point must be at or below to be in front of the camera. setProjection()
  • columnsThisFrame (integer) — Columns drawn this frame
  • lastColumnCount (integer) — Of the last drawTo(): columns it worked out, and whether they were texture rows
  • lastUsedRows (boolean)

QuadColumnTexture

static

A texture drawn by BGE.QuadColumnDrawer, with its columns and rows (1 texel, or a power-of-two slab of texels, wide) cut as roRegions on first use and kept. Rows are drawn rotated a quarter turn, so no transposed copy of the texture is needed. Share one per texture (an atlas frame is its own texture): Renderer.getQuadColumnTexture() caches them by id.

Parameters

  • region (roRegion) — the texture
  • id (string, optional, default: "\"\"")

Properties

  • id (string)
  • x (integer) — the texture's region within its bitmap
  • y (integer)
  • width (integer)
  • height (integer)
  • canMirror (boolean) — Whether columns seen from behind may draw from a flipped copy (see getMirrored()).

Returns

TriangleColumnStrips

static

One set of strips cut across a texture triangle: strip k covers texels starts[k] to ends[k] across, and lows[k] to highs[k] along, drawn from regions[k], its whole slab (invalid if the triangle misses it). For a strip drawn mirrored, cut on first use: mirroredRegions[k] is the slab from a flipped copy, thinRegions[k] its middle texel (see TriangleColumnCuts.getMirroredRegion()).

Properties

  • starts (Array.<integer>)
  • ends (Array.<integer>)
  • lows (Array.<integer>)
  • highs (Array.<integer>)
  • regions (Array.<roRegion>)
  • thinRegions (Array.<roRegion>)
  • mirroredRegions (Array.<roRegion>)

TriangleColumnCuts

static

A textured triangle's texture columns and rows for BGE.QuadColumnDrawer.drawTriangleTo(), each cut to the triangle's span. Strips are a power of two texels wide, and each width is cut on first use and kept, so drawing only projects. Share one per face texture.

Parameters

  • region (roRegion) — the texture
  • points (Array.<BGE.Math.Vector>) — the triangle's 3 texel points within region

Properties

  • isValid (boolean) — false if the UV triangle has no area, so it can't map onto the face
  • u (Array.<float>) — the triangle's texel points
  • v (Array.<float>)
  • ua (float) — (u, v) -> how far along the face's edges 0->1 (a) and 0->2 (b) it is:
  • va (float)
  • ub (float)
  • vb (float)
  • minU (integer) — the texels the triangle covers, whole texels
  • maxU (integer)
  • minV (integer)
  • maxV (integer)
  • mirrorSource (BGE.QuadColumnTexture) — The whole texture, shared by every face using it, whose flipped copies mirrored strips

Returns

PLANE_PRE_PERSPECTIVE_MAX_PIXELS

staticreadonly

A ground plane's top-down bitmap never exceeds this many pixels (the size of the default 1000-unit draw distance at 90 degrees), so reaching farther costs texture sharpness rather than memory or draw time.

Default: 2000000

PlaneScratchBounds

static

Where a rotated texture lands in a scratch bitmap, and how big that bitmap must be.

Properties

  • min (BGE.Math.Vector)
  • width (integer)
  • height (integer)

MAX_DRAW_MODE

staticreadonly

Default: 9

SceneObject

static

Parameters

Properties

  • name (string)
  • id (string) — Unique Id
  • clusterMemberCount (integer) — How many members are in this object's overlap cluster this frame (see
  • drawable (Drawable)
  • type (SceneObjectType)
  • negDistanceFromCamera (float) — The negative distance from the camera, used for depth sorting. Measured from
  • negSortDepth (float) — The negative depth the renderer sorts by: negDistanceFromCamera, or the negative ground
  • distanceFadeAlpha (float) — How faded this object is by the camera's draw-distance fade band, from 1 (fully
  • worldPosition (dynamic)
  • depthPosition (dynamic) — This object's position as used for depth classification (BGE.BSP's dynamic-item
  • bspLeaf (integer) — Renderer-internal: the static tree leaf this object's depthPosition was last found in,
  • bspLeafX (float)
  • bspLeafY (float)
  • bspLeafZ (float)
  • bspTreeVersion (integer)
  • bspLeafUsesCamera (boolean) — whether that leaf also depended on the camera position (BGE.BSP.findBoundsLeaf), so is
  • drawReplayEnabled (boolean) — Whether this type may repeat its last draw's single blit while nothing it depends on
  • replayBlit (object) — The blit to repeat (see Renderer.endBlitCapture()), and what it was drawn with
  • replayFillColor (integer)
  • replayFade (float)
  • replayKey (integer)
  • replayPose (Array.<float>) — For a blit captured while moving: getCameraLockedReplayPose() at the capture
  • replayedLastDraw (boolean) — Whether the last draw() repeated replayBlit
  • transformationMatrix (dynamic) — The Current Transformation Matrix
  • lastFrameWasCulled (boolean) — Whether the last frame's draw was skipped because the frustum rejected this object,
  • visibility (BGE.VisibilityState) — What the last draw (or skip) reported about this object. See getVisibility().
  • lastFrameDidDraw (boolean) — Whether the last frame's draw actually happened. Distinct from lastFrameWasCulled
  • framesWithoutDraw (integer) — Frames in a row nothing was drawn (culled, off canvas or failed); at
  • releaseCachedDrawingsAfterFrames (integer)
  • hasValidWorldPosition (boolean)
  • transformVersion (integer) — Bumped whenever update() recomputes transformationMatrix, so anything derived only
  • hasValidCanvasPosition (boolean)
  • wasEnabledLastFrame (boolean)
  • isFirstFrameSinceEnabled (boolean)
  • isLowEndDevice (boolean)
  • lastGeometryVersion (integer) — The drawable's geometryVersion as of the last completed draw - see geometryChanged()
  • lastQualityVersion (integer) — The renderer's qualityVersion as of the last draw
  • qualityChangedThisDraw (boolean) — True during a draw whose renderer quality settings changed since this object's
  • lastLightingVersion (integer) — The renderer's lightingVersion as of the last draw
  • lightingChangedThisDraw (boolean) — True during a draw of an isShaded drawable whose renderer's lights changed since
  • lastDrawMode (integer) — The draw mode this object last drew in - see drawModeChanged()
  • drawingMode (integer) — The draw mode of the draw under way (or the last one, after it): what a subclass draws or
  • lastProjectionVersion (integer) — The camera's projectionVersion as of the last draw - see projectionChanged()
  • depthChangedThisFrame (boolean) — True for exactly the frame this object's negDistanceFromCamera was recomputed -
  • stableSortKey (float) — What Renderer actually sorts by - negDistanceFromCamera quantized into
  • isStatic (boolean) — Set by Renderer when this object's owning entity is marked GameEntity.isStatic and
  • isOccluder (boolean) — Set by Renderer.markOccluder() when this object hides what's behind it. Not meant
  • occluderFlagSeen (boolean) — The Drawable's isOccluder the Renderer last acted on. Internal.
  • fogCasterFlagSeen (boolean) — The drawable's castsFogSilhouette as of the renderer's last look (see Renderer's fog)
  • occluderDrawPolicy (BGE.OccluderDrawPolicy) — The renderer's occluderDrawPolicy, set by the Renderer for an occluder. Read-only.
  • occludedThisFrame (boolean) — Whether occlusion culling hides this object this frame. Set by the Renderer; read-only.
  • occlusionMapVersion (integer) — The Renderer's occlusion map version occludedThisFrame was judged against, -1 if none.
  • occlusionTestBounds (BGE.OcclusionTestBounds) — The inflated canvas box occludedThisFrame was judged on, or invalid when this object
  • hiddenByWallsThisFrame (boolean) — Whether the walls (BGE.DrawableWalls) hide this object this frame. Set by the Renderer; read-only.
  • staticGeometryMovedThisFrame (boolean) — True for exactly the frame Renderer.updateSceneObjects() should mark the static
  • staticCheckArmed (boolean) — Whether update() has completed at least one prior frame for this object - guards
  • staticWarningLogged (boolean) — Whether the one-time misuse warning has already been logged for this object -
  • staticDrawModeWarningLogged (boolean) — Whether the one-time "static but not in an oriented draw mode" warning has
  • wasStaticEnabledState (boolean) — This object's isEnabled() as of the last checkStaticEnabledStateChanged() call -

Returns

TransformTempBitmapDetails

static

Properties

  • origin (BGE.Math.Vector)
  • rotation (float)
  • scaleX (float)
  • scaleY (float)

TempBitmapDrawResult

static

Properties

  • worked (boolean)
  • didFastDraw (boolean)

RotatedQuadBlit

static

Where drawRegionAsRotatedQuad() blits a region: its top left corner, size and rotation.

Properties

  • x (float)
  • y (float)
  • width (float)
  • height (float)
  • rotation (float) — radians, negated as CornerPoints.getAvgRotation() returns it

SceneObjectBillboard

static

Extends: SceneObject

Parameters

Properties

  • worldPoints (BGE.Math.CornerPoints)
  • canvasPoints (BGE.Math.CornerPoints)
  • canvasPosition (BGE.Math.Vector)
  • surfaceNormal (BGE.Math.Vector)
  • useTempBitmapMap (Array.<boolean>)
  • drawsColumnsThisFrame (boolean) — Whether this frame draws texture columns straight to the canvas
  • usedTransformedFastDrawLastFrame (boolean) — Whether the most recent oriented/solid draw took the cheap rotate+scale fast path

Returns

SceneObjectCircle

static

Extends: SceneObjectBillboard

Draws a DrawableCircle. The fill is inherited, unmodified SceneObjectBillboard machinery (texture columns, tinting, temp-bitmap caching) drawing the renderer's shared circle resource (Renderer.getCircleResource(), built lazily on first use) - exactly like SceneObjectImage, just with a fixed texture instead of one supplied by the drawable. Only the outline differs from a plain Image: it's stroked as an N-gon inscribed in this object's own already-transformed canvasPoints quad (via the generic getOutlineCanvasPoints() hook), which is far cheaper than rasterizing the fill itself as a many-sided polygon and needs no new Renderer draw method.

Parameters

Properties

Returns

SceneObjectImage

static

Extends: SceneObjectBillboard

Parameters

  • name (string)
  • drawableObj (Image)

Properties

  • drawable (Image)
  • frameNumber (integer)

Returns

SceneObjectLine

static

Extends: SceneObject

Parameters

Properties

Returns

SceneObjectModel

static

Extends: SceneObjectBillboard

Parameters

Properties

  • drawable (DrawableModel)
  • occluderPanels (Array.<BGE.OccluderPanel>) — Convex opaque panels merged from the model's faces, in model-local space. Built

Returns

PARALLAX_MAX_TILES_PER_AXIS

staticreadonly

The most tiles a repeating parallax layer draws along one axis

Default: 48

SceneObjectParallaxLayer

static

Extends: SceneObject

Parameters

Properties

Returns

SceneObjectParticle

static

Extends: SceneObject

Draws an entire DrawableParticles emitter's live particles with a single SceneObject

  • not one SceneObject per particle. See specs/2026-08-18-particle-system-design.md ("Why one SceneObjectParticle per emitter, not per particle") for why: per-particle SceneObjects would call Renderer.addSceneObject/removeSceneObject every frame during continuous emission, permanently defeating the depth-sort skip-optimization for the whole renderer.

Parameters

Properties

Returns

PerspectiveCalculationResult

static

Properties

  • actual (BGE.Math.CornerPoints)
  • mapped (BGE.Math.CornerPoints)

PerspectiveSlice

static

One horizontal band of the ground: a whole-pixel source rect of the top-down bitmap, and where/how much to scale it on the composite.

Properties

  • srcX (integer)
  • srcY (integer)
  • srcWidth (integer)
  • srcHeight (integer)
  • destX (float)
  • destY (float)
  • scaleX (float)
  • scaleY (float)
  • exactSrcLeft (float) — the exact (fractional) source span that should fill the frame width
  • exactSrcWidth (float)
  • nearDepth (float) — camera-forward depths of the band's near and far edges
  • farDepth (float)

PlaneLightPoolPlacement

static

A light pool placed in the plane's top-down bitmap: its bounding box, in pixels.

Properties

  • pool (BGE.Lighting.PlaneLightPool)
  • x (float)
  • y (float)
  • width (float)
  • height (float)
  • rgba (integer) — the gradient's draw color: the light's hue, its strength as alpha

SceneObjectPlane

static

Extends: SceneObject

Parameters

Properties

Returns

SceneObjectPolygon

static

Extends: SceneObjectBillboard

Parameters

Properties

Returns

SceneObjectRectangle

static

Extends: SceneObjectBillboard

Draws a DrawableRectangle. Extends SceneObjectBillboard, so a rectangle orients and foreshortens in 3D in the oriented draw modes and stays screen-aligned in the direct ones, exactly like an image does.

Unlike an image, though, a rectangle has no texture to sample: it's a single flat color. So filling the projected quad (or tinting a shared white column texture) is all it needs, and DrawableRectangle never has to hold a bitmap of its own. This is how SceneObjectPolygon draws, for the same reason.

It does still cache that fill into a temp bitmap in the oriented draw modes, exactly like a polygon: filling a rotated quad means rasterizing two triangles through scratch bitmaps, which is far too expensive to repeat every frame for an object that hasn't moved. In the direct (billboard) draw modes there's nothing worth caching - the draw is already a single DrawRect - so those skip the temp bitmap entirely.

Parameters

Properties

Returns

SceneObjectSkybox

static

Extends: SceneObject

Parameters

Properties

Returns

SceneObjectText

static

Extends: SceneObjectBillboard

Parameters

Properties

Returns

SceneObjectVoxelTerrain

static

Extends: SceneObject

Draws a DrawableVoxelTerrain: marches a VoxelTerrainView from the camera whenever anything that shapes it changes (otherwise draws last frame's spans again), straight to the target, or with roll into a level view as wide as the frame's diagonal that's rotated on.

Parameters

Properties

  • drawable (DrawableVoxelTerrain)
  • view (BGE.VoxelTerrainView) — The march: its spans are in level-view pixels
  • marchedLastFrame (boolean) — Whether the last draw marched (false: it reused the spans) and was rolled
  • rolledLastFrame (boolean)
  • redrawsLastFrame (integer) — Spans drawn again over objects in the last frame

Returns

SceneObjectWall

static

Extends: SceneObjectImage

A BGE.DrawableWall's quad: built from its floor ends and heights, drawn as an image, with its texture tiled when the wall asks for it.

Parameters

Properties

Returns

SceneObjectWalls

static

Extends: SceneObject

Draws a DrawableWalls: walks its WallsView each time the camera changes, then draws the visible strips far to near.

Parameters

Properties

  • drawable (DrawableWalls)
  • view (BGE.WallsView) — This frame's strips and the depth windows that hide things behind walls.
  • raysLastFrame (integer) — Rays in the fan and strips drawn by the last draw, and how many of those were fog strips
  • stripsDrawnLastFrame (integer)
  • fogStripsDrawnLastFrame (integer)

Returns

VoxelHideBox

static

Extends: roAssociativeArray

Where a voxel terrain is seen from, in the map's units: built each frame by SceneObjectVoxelTerrain from the camera. An object's box in a terrain's level view, from SceneObjectVoxelTerrain.testHidden(), for redrawing the hills over it.

Properties

  • top (float)
  • bottom (float)
  • firstColumn (integer)
  • lastColumn (integer)
  • limit (float) — level depth: hills nearer than this are redrawn

VoxelTerrainPose

static

Extends: roAssociativeArray

Properties

  • camX (float) — Camera position on the map, in cells
  • camZ (float)
  • camHeight (float) — Camera height in height units (the map's 0-255 scale)
  • forwardX (float) — The level view direction and its right, on the map plane (unit length)
  • forwardZ (float)
  • rightX (float)
  • rightZ (float)
  • focal (float) — Focal length in pixels
  • viewWidth (float) — Size of the level view being marched, in pixels
  • viewHeight (float)
  • horizon (float) — Screen y of the horizon in the level view (horizon shift pitch)
  • pitch (float) — Pitch in radians, looking up positive, for exactPitch
  • exactPitch (boolean) — Project each step with the pitched camera instead of shifting the horizon
  • distance (float) — How far to march, in cells
  • cellSize (float) — World units per cell and per height unit
  • heightScale (float)

VoxelTerrainView

static

The march of a voxel (heightmap) terrain, with no drawing: for each screen column, a ray steps front to back over the map, and wherever the terrain rises above what the column already shows it adds a span. Spans in a column never overlap, run upward from the view's bottom with increasing depth, and same-coloured neighbours merge.

Steps double every bandSteps steps; each band samples the mip level whose cells are about as far apart as its samples (the coarser of the gap between columns and the step), which keeps far terrain from flickering. Map positions are 16.16 fixed point. See specs/2026-11-21-voxel-terrain-spike.md.

Parameters

Properties

  • columns (integer) — Columns across the view
  • bandSteps (integer) — Steps in each depth band
  • fogColor (integer) — RGB colour far terrain blends towards (-1 for none), from fogStart (a fraction of the
  • fogStart (float)
  • columnSpans (dynamic) — Per column, its spans from the last march: top, height, RGBA colour and the depth (world
  • columnTops (dynamic) — Per column, each place its top rose: depth (world units) then the new top, repeated, in
  • columnWidth (float) — Width of each column in pixels
  • viewHeight (float) — Height of the level view last marched
  • spanCount (integer) — Spans and depth steps in the last march
  • stepCount (integer)

Returns

WallSegment

static

One wall of a BGE.DrawableWalls: an upright quad between two floor points, in world space. Make them with BGE.createWallSegment().

Properties

  • ax (float)
  • az (float)
  • bx (float)
  • bz (float)
  • bottom (float)
  • top (float)
  • texture (string) — Texture name (a key of DrawableWalls.textures)
  • tileWidth (float) — World units one texture copy covers along the wall, or 0 to stretch it over the wall
  • tileCount (integer) — Texture copies stacked up the wall
  • normalX (float) — The side a one-sided wall is seen from (unit, on the floor plane)
  • normalZ (float)
  • twoSided (boolean)
  • length (float)

WallSegmentOptions

static

Properties

  • tileWidth (float) — World units one texture copy covers along the wall; 0 (default) stretches it
  • tileHeight (float) — World units one texture copy covers up the wall, rounded so a whole number fit; 0
  • twoSided (boolean) — Seen from both sides (default false: only from the left of start -> end, looking down)

WallsBsp

static

A 2D BSP over wall segments in plan, built once, that lists them front to back from any eye point (BGE.WallsView walks them in that order). A segment crossing another's line is split into parts there; part k covers partStart[k]..partEnd[k] (0..1) of segment partSegment[k], from (partAx, partAz) to (partBx, partBz).

Parameters

Properties

  • partSegment (Array.<integer>)
  • partStart (Array.<float>)
  • partEnd (Array.<float>)
  • partAx (Array.<float>)
  • partAz (Array.<float>)
  • partBx (Array.<float>)
  • partBz (Array.<float>)
  • root (integer) — Root node, or -1 with no segments
  • nodeX (Array.<float>) — Per node: a point on its line and the line's normal, its front (the normal's side) and
  • nodeZ (Array.<float>)
  • nodeNx (Array.<float>)
  • nodeNz (Array.<float>)
  • nodeFront (Array.<integer>)
  • nodeBack (Array.<integer>)
  • nodeFirst (Array.<integer>)
  • nodeCount (Array.<integer>)
  • nodeParts (Array.<integer>)
  • nodeMinX (Array.<float>) — Per node: the plan bounds of its parts and everything under it
  • nodeMinZ (Array.<float>)
  • nodeMaxX (Array.<float>)
  • nodeMaxZ (Array.<float>)
  • segmentCount (integer) — How many segments it was built from

Returns

WallsSpan

static

A run of rays covering some world points, filled by WallsView.findSpan().

Properties

  • valid (boolean)
  • firstRay (integer)
  • lastRay (integer)
  • nearestDistance (float) — The smallest forward depth of the points, measured along the level forward vector.
  • anyAboveWalls (boolean) — True if some point's sight line clears the wall top at the wall's depth, so it can show

WallsView

static

Works out which wall strips a BGE.DrawableWalls shows each frame, DOOM-style: no ray is cast against the level. The segments in view are walked front to back (BGE.WallsBsp) and projected onto a fan of rays across the screen, one strip per ray. Each ray keeps an open window of elevation slopes, (height - eye) / forward depth, that nearer walls narrow: a wall on the floor closes it up to its top, one reaching above the screen closes it down to its foot. A closed ray costs nothing more, so cost follows screen coverage, and a short wall leaves taller ones behind it showing.

Every wall point on one ray's bearing lies in one vertical plane through the eye, which projects to one screen line, so the window is exact at any pitch.

Pieces are recorded front to back (per ray: pieceNext from rayFirstPiece) and drawn back to front; a piece partly behind a nearer short wall is drawn whole and painted over.

Parameters

Properties

  • rayCount (integer)
  • firstTan (float)
  • tanStep (float)
  • levelForward (BGE.Math.Vector)
  • levelRight (BGE.Math.Vector)
  • originX (float)
  • originY (float)
  • originZ (float)
  • hideTolerance (float) — How much nearer than a point a wall must be to hide it, in forward depth (strips round
  • allowLevelPath (boolean) — A level, unrolled camera takes a shorter path; false always takes the general one (tests).
  • lodDepth (float) — Forward depth past which walls (level or pitched, unrolled camera) draw one strip per two
  • pieceCount (integer) — Pieces of the last update(), grown and never shrunk; meaningful below pieceCount.
  • pieceSegment (Array.<integer>)
  • pieceAlong (Array.<float>) — 0..1 along the segment
  • pieceDepth (Array.<float>) — Forward depth (along levelForward)
  • pieceX (Array.<float>) — The strip's foot on the canvas, its foot-to-top length, width and lean (degrees, as
  • pieceY (Array.<float>)
  • pieceLength (Array.<float>)
  • pieceWidth (Array.<float>)
  • pieceAngle (Array.<float>)
  • pieceRay (Array.<integer>)
  • pieceWide (Array.<boolean>) — Whether the piece also covers the ray left of its own (see lodDepth)
  • pieceNext (Array.<integer>) — The ray's next piece further away, or -1
  • pieceSlopeLow (Array.<float>) — The wall's elevation slopes at the piece, foot and top
  • pieceSlopeHigh (Array.<float>)
  • recordSurfaces (boolean) — With recordSurfaces on, update() also lists the floor and ceiling each ray sees between
  • floorCount (integer)
  • floorRay (Array.<integer>)
  • floorTop (Array.<float>)
  • floorBottom (Array.<float>)
  • floorRunCount (integer)
  • floorRunY (Array.<float>)
  • floorRunFirst (Array.<integer>)
  • ceilingCount (integer)
  • ceilingRay (Array.<integer>)
  • ceilingTop (Array.<float>)
  • ceilingBottom (Array.<float>)
  • ceilingRunCount (integer)
  • ceilingRunY (Array.<float>)
  • ceilingRunFirst (Array.<integer>)
  • rayFirstPiece (Array.<integer>) — Per ray: the nearest piece (-1 for none), the forward depth its window closed at and the
  • rayCloseDepth (Array.<float>)
  • rayNearestDepth (Array.<float>)
  • nearestWallDepth (float) — The least of rayNearestDepth this frame: nothing nearer than this can be behind a wall
  • partsInView (integer) — BSP parts (segments, split where walls cross) the last update() found in view, and
  • partsVisited (integer)

Returns

ExitArea

static

Where a scene exit is - see BGE.SceneExits. Subclass it and override contains() for another shape. Positions are read on plane: xz (the default) is the ground in a 3D game, xy a 2D game.

Properties

RectExitArea

static

Extends: ExitArea

An axis-aligned rectangle, its low edges inside and its high edges not.

Parameters

  • x (float) — the low x edge
  • y (float) — the low y edge (z on the xz plane)
  • width (float)
  • height (float) — along y (z on the xz plane)
  • plane (BGE.SeparationPlane, optional, default: "BGE.SeparationPlane.xz")

Properties

  • x (float)
  • y (float) — z on the xz plane
  • width (float)
  • height (float)

Returns

CircleExitArea

static

Extends: ExitArea

A circle round a point, e.g. walking up to a door; its edge isn't inside.

Parameters

  • center (BGE.Math.Vector)
  • radius (float)
  • plane (BGE.SeparationPlane, optional, default: "BGE.SeparationPlane.xz")

Properties

  • center (BGE.Math.Vector)
  • radius (float)

Returns

GridCellsExitArea

static

Extends: ExitArea

A block of cells in a grid, e.g. a tile map's doorway. Cell [0, 0]'s low corner is at (originX, originY) and columns run along x.

Parameters

  • originX (float) — x of cell [0, 0]'s low corner
  • originY (float) — y (z on the xz plane) of cell [0, 0]'s low corner
  • cellSize (float)
  • col (integer) — the block's first column
  • row (integer) — the block's first row
  • cols (integer, optional, default: 1)
  • rows (integer, optional, default: 1)
  • plane (BGE.SeparationPlane, optional, default: "BGE.SeparationPlane.xz")

Properties

  • originX (float)
  • originY (float) — z on the xz plane
  • cellSize (float)
  • col (integer)
  • row (integer)
  • cols (integer)
  • rows (integer)

Returns

SceneExit

static

One way out of a scene: an area, and the scene (and args) walking into it changes to - see BGE.SceneExits. Subclass it and override isTriggeredBy() for another condition, e.g. only on a button press, or while a door is unlocked.

Parameters

  • area (BGE.ExitArea)
  • sceneName (string)
  • args (roAssociativeArray, optional, default: "{}")

Properties

  • area (BGE.ExitArea)
  • sceneName (string)
  • args (roAssociativeArray) — Passed to the next scene, e.g. {spawn: "gate"} for its BGE.SpawnPoints
  • enabled (boolean) — A disabled exit is never taken by SceneExits.update()
  • fadeSeconds (float) — Each half of the fade; 0 or less changes scene straight away

Returns

SceneExits

static

A scene's ways out: areas that change to another scene when the player walks in. Each visit leaves once - after the first exit is taken the rest are ignored, so a player standing in a doorway during the fade doesn't ask again. If the change is refused (another transition is running) nothing is used up and the next update() tries again.

A scene makes one in onCreate() (scenes are reused, so make a new one or clear() it each visit), adds its exits, and calls update() with the player's position each frame - from onPostUpdate() to see where everyone ended up this frame. Shapes: BGE.RectExitArea, BGE.CircleExitArea, BGE.GridCellsExitArea, or subclass BGE.ExitArea. Subclass BGE.SceneExit for another trigger condition, and this class to change scene some other way (changeSceneFor()) or react to leaving (onLeave()). trigger() takes an exit directly, e.g. from a collider's onCollisionEnter().

Parameters

Properties

  • enabled (boolean) — While false, update() takes no exits
  • game (BGE.Game)
  • exits (Array.<BGE.SceneExit>) — In the order added: the first that triggers wins

Returns

Example

CODE
m.exits = new BGE.SceneExits(m.game)
m.exits.add(new BGE.RectExitArea(-100, 380, 200, 40), "TownScene", {spawn: "gate"})
m.exits.add(new BGE.CircleExitArea(m.doorPosition, 60), "ChapelScene")
' in onPostUpdate():
m.exits.update(m.player.position)

SpawnPoint

static

A named place a scene can put the player when it starts - see BGE.SpawnPoints. Subclass it to keep more with each spawn, e.g. a four-way facing for a 2D sprite.

Parameters

  • id (string)
  • position (BGE.Math.Vector)
  • heading (float, optional, default: "0.0") — radians

Properties

  • id (string)
  • position (BGE.Math.Vector)
  • heading (float) — Which way the player faces there, in radians. In a 3D game heading 0 faces -z (see

Returns

SpawnPoints

static

The places a scene can start the player, by id, and which one this visit's args ask for. A scene makes one in onCreate() (scenes are reused, so make a new one or clear() it each visit), adds its spawns, then resolves the args it was changed to with. An exit into the scene names a spawn in its args, e.g. {spawn: "gate"} - see BGE.SceneExits.

Parameters

  • argName (string, optional, default: "\"spawn\"") — the args field resolve() reads the spawn id from

Properties

  • argName (string) — The args field resolve() reads the spawn id from

Returns

Example

CODE
m.spawns = new BGE.SpawnPoints()
m.spawns.add("gate", BGE.Math.VectorOps.create(0, 0, 400), BGE.Math.PI)
m.spawns.add("start", BGE.Math.VectorOps.create(0, 0, 0))
spawn = m.spawns.resolve(args, "start")
m.player.position.x = spawn.position.x
m.player.position.z = spawn.position.z
m.player.rotation.y = spawn.heading

VoxelMapOptions

static

Extends: roAssociativeArray

Options for BGE.VoxelMaps.fromArrays().

Properties

  • edgeMode (string) — BGE.VoxelEdgeMode, default wrap
  • flatHeight (integer) — Height (0-255) past the edges with edgeMode flat
  • flatColor (integer) — Palette index past the edges with edgeMode flat

VoxelMap

static

A heightmap terrain's data: a square grid of heights (0-255) and colours (palette indexes), with mip levels, where level n averages 2^n x 2^n cells. Each level is an roByteArray, cell (x, z) at index (z << levelShift) + x. A colour index past the palette draws as palette colour 0 (only fromArrays() checks them).

Make one with BGE.VoxelMaps.fromFile() (a .bvox from tools/voxel-map.py; the fast way), BGE.VoxelMaps.fromArrays(), BGE.VoxelMaps.fromLevels() or BGE.VoxelMapGenerator.

Parameters

  • sizeShift (integer) — log2 of the size
  • palette (Array.<integer>) — RGB colours
  • heightLevels (Array.<roByteArray>) — per level, level 0 first
  • colorLevels (Array.<roByteArray>) — per level, level 0 first

Properties

  • size (integer) — Cells along each side, a power of 2
  • sizeShift (integer) — log2(size)
  • mask (integer) — size - 1
  • palette (Array.<integer>) — RGB colours (0xRRGGBB), at most 256
  • heightLevels (Array.<roByteArray>) — Heights per level, level 0 (full size) first
  • colorLevels (Array.<roByteArray>) — Palette indexes per level, level 0 first
  • edgeMode (string) — BGE.VoxelEdgeMode
  • flatHeight (integer) — Height past the edges with edgeMode flat
  • flatColor (integer) — Palette index past the edges with edgeMode flat

Returns

VoxelBiome

static

Extends: roAssociativeArray

A height band of a generated map and its colour.

Properties

  • top (integer) — Heights below this (and at or above the previous biome's top) are this biome; the last
  • rgb (integer) — RGB (0xRRGGBB)

VoxelMapGeneratorOptions

static

Extends: roAssociativeArray

Options for BGE.VoxelMapGenerator.

Properties

  • size (integer) — Cells along each side, a power of 2 from 64 to 1024 (default 256)
  • seed (integer) — The same seed makes the same map (default 12345)
  • roughness (float) — How much each finer level of detail keeps of the one before: lower is smoother
  • seaLevel (integer) — Heights below this (0-255) are flattened to it, as water (default 70)
  • biomes (Array.<VoxelBiome>) — Height bands, lowest first (default: water, sand, grass, forest, rock, snow)
  • slopeShading (boolean) — Shade by slope, lit from the north-west (default true)

VoxelMapGenerator

static

Generates a tileable BGE.VoxelMap: diamond-square heights, coloured by height band (biome) in 4 shades by slope. Each mip level is re-shaded from its own averaged heights.

Slow: a 256 map takes ~1.3 s on a Roku Ultra, long enough to risk the watchdog on slower devices, so games should load a baked map (tools/voxel-map.py, or saveToFile() a generated one) instead.

Palette: biome b in shade s (0-3, darkest first) is index b * 4 + s.

Parameters

Properties

  • size (integer)
  • seed (integer) — Negative seeds are made positive
  • roughness (float)
  • seaLevel (integer)
  • biomes (Array.<VoxelBiome>) — Empty for the defaults
  • slopeShading (boolean)

Returns

CountdownTimer

static

A simple dt-driven countdown: start it with a duration, tick() it once per frame (typically from GameEntity.onUpdate()'s own dt), and check isActive() to see if time remains. Replaces a hand-rolled "duration constant + live timer field + manual decrement-and-clamp block" pattern - the same shape used for coyote time, jump/input buffering, invulnerability windows, hit-flash timers, cooldowns, etc.

This is not the same as BGE.GameTimer, which wraps a wall-clock roTimespan (mark()/totalMilliseconds()) for measuring real elapsed time - CountdownTimer is purely dt-driven and has no idea what real time it is.

Returns

Health

static

Hit points: current and max, with an optional invulnerability window after each hit. damage() says whether the hit killed. Flashes, knockback and sounds stay with the entity, or go in the onDamaged()/onDeath() hooks of a subclass. Call update(dt) once per frame if you use invulnerableSeconds.

Parameters

  • max (float, optional, default: 100)

Properties

  • max (float)
  • current (float)
  • invulnerableSeconds (float) — After each hit that lands, further hits are ignored for this long. 0 for none.

Returns

Example

CODE
m.health = new BGE.Health(6)
m.health.invulnerableSeconds = 1.0
' When something hits the player:
if m.health.canTakeDamage()
if m.health.damage(1)
m.startDefeat()
end if
end if
' In onUpdate(dt):
m.health.update(dt)

Impulse

static

A short push, such as a knockback, that an entity ticks once per update. step(dt) returns how far to move this frame, so the entity can add it to its position or route it through its own collision (e.g. BGE.SolidWorld.moveAndSlide()).

Two shapes: start() eases out (the velocity decays each step until it falls below a stop speed), and startTimed() moves at a constant velocity for a set time.

Properties

  • velocity (dynamic) — Current velocity, in units per second (or per step unit; see step()).

Returns

Example

CODE
' On a hit: 600 units/s away from the attacker, easing out
m.knockback.start(BGE.Math.VectorOps.scale(away, 600), 10)
' In onUpdate(dt):
push = m.knockback.step(dt)
m.position.x += push.x
m.position.z += push.z

Interactable

static

Something the player can interact with - see BGE.Interactables.

Parameters

Properties

  • entity (BGE.GameEntity)
  • id (string)
  • label (string) — Shown in the prompt, e.g. "Talk to Bram".
  • enabled (boolean) — A disabled interactable is never picked.
  • radius (float) — Its body radius in world units, so it counts as soon as its edge is in reach (arcs only).
  • data (dynamic) — Anything else the game wants to keep with it (a story node, a shop id...).

Returns

Interactables

static

The things a player can talk to, open or pick up, and which one is "in front" right now. Entities that have been destroyed are skipped (and dropped by prune()).

  • nearestInArc(): 3D, on the ground plane - the nearest within reach and halfAngle of a heading (heading 0 faces -z; see BGE.Math.isWithinArc()).
  • nearestInRect(): 2D - the nearest whose position is inside a rectangle.

Example

CODE
m.talkers = new BGE.Interactables()
m.talkers.add(bram, "bram", "Talk to Bram", "bramNode")
target = m.talkers.nearestInArc(knight.position, knight.rotation.y, 3.5, BGE.Math.PI / 3)
if target <> invalid
prompt = m.talkers.promptFor(target, "OK") ' "OK: Talk to Bram"
end if

LaunchParams

static

Typed access to deep-link/launch params: the args Main() gets (e.g. rokubot launch dev --param level=3), or any args AA such as a scene's.

Launch params arrive as strings, sometimes wrapped in one-element arrays, and the AA itself can come wrapped too; the getters unwrap both. A value that's missing or doesn't parse gives the default, so level=abc doesn't quietly become level 0.

Parameters

  • args (dynamic, optional, default: "invalid") — Main()'s args, a one-element array holding them, or invalid

Returns

Example

CODE
sub Main(args as dynamic)
params = new BGE.LaunchParams(args)
game = new BGE.Game(1280, 720)
if not game.applyLaunchQuality(params)
game.enableAdaptiveQuality()
end if
' ... defineScene() calls ...
game.changeScene(params.sceneName(game.getSceneNames(), "TitleScene"), {
level: params.getInt("level", 1, 1, 9)
})

MotionChecker

static

Properties

  • previousTransform (dynamic)
  • movedLastFrame (boolean)

RegenPool

static

A resource that actions spend and that refills on its own after a pause: stamina, mana, ammo, boost or dash charges. Call update(dt) once per frame.

By default any amount left is enough to start an action, which can take the pool down to zero (souls-style stamina). Set requireFullAmount for mana or ammo, where an action needs all of its cost. A refused spend starts a short "denied" window (isDenied()) for a HUD to flash, and calls onDenied().

Parameters

  • max (float, optional, default: 100)

Properties

  • max (float)
  • current (float)
  • regenPerSecond (float) — Per second, once regenDelaySeconds have passed since the last spend
  • regenDelaySeconds (float)
  • slowedRegenFactor (float) — Fraction of the regen rate while update() is told the pool is slowed (e.g. holding a block)
  • requireFullAmount (boolean) — When true, spend() refuses unless the whole amount is there. When false, any amount left
  • deniedSeconds (float) — How long isDenied() stays true after a refused spend

Returns

Example

CODE
m.stamina = new BGE.RegenPool(100)
m.stamina.regenPerSecond = 50
' In onUpdate(dt):
if dodgePressed and m.stamina.spend(28)
m.startDodge()
end if
m.stamina.update(dt, m.isBlocking) ' regenerates slower while blocking

RespawnTimer

static

The wait between a death and the respawn. Call start() when the player dies and update(dt) once per frame; update() returns true (and calls onRespawn()) on the frame the delay runs out. What a respawn does is up to the owner: reset the scene, send the player to a spawn point, refill health. Do it where update() returns true, or subclass and override onRespawn(). progress() can drive a fade or a countdown while waiting.

Parameters

  • delaySeconds (float, optional, default: "3.0")

Properties

  • delaySeconds (float) — Seconds from start() to the respawn. Changing it mid-wait takes effect straight away.

Returns

Example

CODE
m.respawn = new BGE.RespawnTimer(2.0)
' When the player dies:
m.respawn.start()
' In onUpdate(dt):
if m.respawn.update(dt, not m.game.isTransitioning())
m.game.resetScene()
end if

SaveSlot

static

A versioned save in the device registry. What goes in it is up to the game: write() any JSON-friendly value and read() it back. It's stored as {version, data}.

read() only returns a save that can be used: one written with this version, or an older one migrate() upgrades, that passes the validate function if one's given. Anything else reads as invalid, so "Continue" can be shown with exists(validate).

Set enabled = false to stop it reading or writing (e.g. while a deep link is testing a level). Subclass and override migrate() to upgrade old saves.

Parameters

  • section (string) — registry section, e.g. your game's id
  • key (string, optional, default: "\"save\"")
  • version (integer, optional, default: 1) — bump when the save's shape changes

Properties

  • section (string)
  • key (string)
  • version (integer)
  • enabled (boolean) — While false, read() returns invalid and write()/delete() do nothing.

Returns

Example

CODE
slot = new BGE.SaveSlot("my-game", "save", 2)
slot.write({level: 3, coins: 40})
save = slot.read(validateMySave) ' function(data) as dynamic: data, or invalid if bad

SaveProfile

static

Data that lasts across saves and new games - settings, unlocks, endings found, high scores - as named values in one registry key. Every change is written straight away.

Parameters

  • section (string) — registry section, e.g. your game's id
  • key (string, optional, default: "\"profile\"")

Properties

  • section (string)
  • key (string)
  • enabled (boolean) — While false, changes aren't written (reads still work from what's loaded).

Returns

Example

CODE
profile = new BGE.SaveProfile("my-game")
if profile.recordHighScore("arcade", score)
' a new best
end if

StateClock

static

A state name and how long it's been in it, for state-machine entities (enemy AI, a player's attack/dodge/hurt states, a boss's phases). Call update(dt) once per frame, at the top of onUpdate(), then branch on state.

set() enters an open-ended state; setTimed() one that lasts a set time (isTimeUp(), remainingFraction()). justEntered() is true for the first update after a state is entered, for one-off entry work. Optionally, give it a sprite and play() switches its animation only when the name changes. Subclass and override onEnter() for anything else.

Parameters

  • state (string, optional, default: "\"\"") — the starting state (not "entered": justEntered() stays false)

Properties

  • state (string) — The current state
  • previousState (string) — The state before this one
  • seconds (float) — Seconds since the state was entered, counted by update()
  • sprite (BGE.Sprite) — Optional: play() switches this sprite's animation
  • orientedSprite (BGE.DrawableOrientedSprite) — Optional: play() switches this sprite's oriented animation (playOrientedAnimation())
  • animation (string) — The animation play() last switched to

Returns

Example

CODE
m.clock = new BGE.StateClock("idle")
m.clock.sprite = m.sprite
' In onUpdate(dt):
m.clock.update(dt)
if m.clock.state = "windup"
if m.clock.seconds >= 0.4
m.clock.setTimed("strike", 0.25)
m.clock.play("strike")
end if
else if m.clock.state = "strike"
if m.clock.justEntered()
m.playSound("swing")
end if
if m.clock.isTimeUp()
m.clock.set("idle")
m.clock.play("idle")
end if
end if

SomeConst

staticreadonly

Default: 23

TagList

static

Returns

TargetCandidate

static

Anything BGE.Targeting can pick: an entity (or subclass), or an AA with a position.

Properties

  • position (BGE.Math.Vector)

TargetingOptions

static

Extends: roAssociativeArray

Options for BGE.Targeting's functions. Every field is optional.

Properties

  • plane (BGE.SeparationPlane) — Which axes positions use: xz (default) for the ground in a 3D game, xy for a 2D game.
  • angleWeight (float) — How much pickInView() favours targets near the view heading over near ones: a target's

TokenPool

static

Hands out a limited number of tokens, e.g. the "attack token" AI pattern: at most maxHolders enemies attack at once, and after one finishes nobody else starts for cooldownSeconds, so attacks come one after another rather than all at once.

Holders are identified by an id (a GameEntity's id, or any string or integer), since = can't compare objects. Call update(dt) once per frame.

Parameters

  • maxHolders (integer, optional, default: 1)
  • cooldownSeconds (float, optional, default: 0)

Properties

  • maxHolders (integer) — How many ids can hold a token at once
  • cooldownSeconds (float) — After any token is released, nobody can take one for this long

Returns

Example

CODE
m.attackTokens = new BGE.TokenPool(1, 1.2)
' In an enemy's onUpdate:
if inRange and m.attackTokens.request(m.id)
m.startAttack()
end if
' When its attack is over, or it dies:
m.attackTokens.release(m.id)

TEXT_MAX_LINE_SIZE

staticreadonly

The widest line of text measured for drawing, in pixels - text images are sized from it

Default: 1920