Skip to content

Globals ​

Besides bare, a few helpers are available everywhere without an import.

Waiting ​

ts
await wait(0.5);        // wait half a second
await waitFrame();      // wait one game frame
await waitFrame(3);     // wait three game frames
FunctionDescription
wait(seconds, persistent?)Resolves after a number of seconds.
waitFrame(frames?, persistent?)Resolves after a number of game frames (fixed updates), so movement and collisions have run in between. Default 1.
cancelWaits()Cancels every pending wait that isn't persistent.

Logging and checks ​

FunctionDescription
trace(...values)Like console.log, but only on the dev server, so it stays quiet in your released game.
assert(condition, message?)Throws an error with message when condition is false.

Values ​

GlobalDescription
bSceneThe current scene, rewritten to this or this.scene like the scene modules.
rapidThe renderer. See below.
debugWhether debug drawing is on. See Debugging.
isDevRunning from the Vite dev server (__DEV__), not a production build.
isMobileRunning on a phone or tablet.
hasFocusThe game's tab has focus.

The renderer ​

Bare renders with Rapid, a fast WebGL renderer, available as the global rapid. Its classes are exported from bare-engine: Texture, RenderTexture, TextTexture, ParticleEmitter, and more. Use them when the engine's own API isn't enough, for example rapid.setTextureFilter(TextureFilterMode.NEAREST).

See the Rapid.js documentation for everything it can do.

Bare Engine is open source under the MIT license.