Assets
Functions for managing assets.
Boolean Assets.exists(path);
// Check if asset exists
String path // path for asset
Boolean Assets.loaded(path);
// Check if asset is loaded
String path // path for asset
Int32 Assets.loadedAssetCount();
// Get the number of loaded assets
Void Assets.unload(path);
// Unload an asset
String path // path to the asset
Void Assets.unloadAll();
// Unload all assets
String Assets.list(directory, subdirectories);
// Returns a list of the paths to all assets, delimited with a comma `,`
String directory // (optional) provide a directory to list
Boolean subdirectories //
String Assets.readText(path);
// Returns a string containing the text of the file at the given path.
String path // Path of the asset to read
Void Assets.writeText(path, data);
// Creates or overwrites a file in the assets directory.
String path // Path of the asset to create or overwrite
String data // A string containing the data to write
{int w, int h} Assets.getTextureSize(path);
// Returns the size of a specified texture.
String path // Path of the texture
Texture Assets.getTexture(path);
// Returns a Texture object from the given asset path. The Texture section below outlines the texture API
String path // Path of the texture
Texture Assets.createTexture(width, height);
// Create a new, blank texture object.
Int32 width // width of the texture, in pixels
Int32 height // height of the texture, in pixels
String Assets.createMesh(meshData);
// Creates a new mesh object and returns a reference for it.
{vertices [, indices, uvs, uv2s, normals, tangents, colors, texture]} meshData // Data to create the mesh with, all parameters other than vertices are optional.
String Assets.createVoxelMesh(chunkSize, texturePath, textureSize, data);
// Creates a new mesh object from voxel data returns a reference for it.
{x, y, z} chunkSize // Dimensions of voxel area
String texturePath // Texture to use for the voxels. This should be a map of smaller textures, like a tileset.
{x, y} textureSize // How many individual textures along each axis of your texture map
int[] data // Integer array defining the voxels. -1 means empty, any other number specifies a texture in the texture map
Audio
Functions for playing sounds! neat
Void Audio.playMusic(audioPath);
// Loop a given audio file
String audioPath // path to the audio asset to play
Void Audio.playSound(audioPath, volume, pitch);
// Play a given audio file once
String audioPath // path to the audio asset to play
Double volume // (optional) volume to play audio at. 1 = default
Double pitch // (optional) pitch to play audio at. 1 = default
Void Audio.setMainVolume(volume);
// Set overall audio volume
Double volume // volume to set. 1.0 = default
Void Audio.stopAllSound();
// Stop all playing sounds, except music
Void Audio.stopMusic();
// Stop the playing music
Color
A list of handy colors to use!
ObjectInstance Color.black;
// black
ObjectInstance Color.gray;
// gray
ObjectInstance Color.white;
// white
ObjectInstance Color.red;
// red
ObjectInstance Color.meat;
// meat
ObjectInstance Color.darkbrown;
// darkbrown
ObjectInstance Color.brown;
// brown
ObjectInstance Color.orange;
// orange
ObjectInstance Color.yellow;
// yellow
ObjectInstance Color.darkgreen;
// darkgreen
ObjectInstance Color.green;
// green
ObjectInstance Color.slimegreen;
// slimegreen
ObjectInstance Color.nightblue;
// nightblue
ObjectInstance Color.seablue;
// seablue
ObjectInstance Color.skyblue;
// skyblue
ObjectInstance Color.cloudblue;
// cloudblue
ObjectInstance Color.disaster;
// disaster engine brand yellow
Debug
Various debugging tools.
Void Debug.toggleProfileGraph();
// Toggle the debug profiler graph. This shows how long each frame took to compute.
Void Debug.log(message);
// Print a message to the system console
String message // The message to print
String Debug.ilAnalysis(sourcePath);
// Return the disassembled IL of a script after compilation. Useful for debugging hopefully
String sourcePath // path to the script to analyze
Double Debug.scriptTime;
// Time taken to run all the scripts last frame, in seconds! 0.016s == 60fps
Draw
All your favourite ways to draw stuff to the screen!
Void Draw.loadFont(fontPath);
// Load a font for the software renderer. All future Draw.text calls will use the specified font.
String fontPath // Path to the font texture. Fonts are 2-color images where pixels with a red value above zero are considered filled.
Void Draw.clear();
// Clear the 2D canvas.
Void Draw.offset(x, y);
// Set a global offset for 2D rendering.
Int32 x // Pixels in the x axis to offset by
Int32 y // Pixels in the y axis to offset by
Void Draw.rect(x, y, width, height, color, filled);
// Draw a rectangle
Int32 x // x position of the rectangle
Int32 y // y position of the rectangle
Int32 width // width of the rectangle
Int32 height // height of the rectangle
{r, g, b, a} color // Rectangle color
Boolean filled // (optional) Draw a filled rect (true) or an outline (false, default)
Void Draw.triangle(x1, y1, x2, y2, x3, y3, color, filled);
// Draw a triangle
Int32 x1 // x position of the first point
Int32 y1 // y position of the first point
Int32 x2 // x position of the second point
Int32 y2 // y position of the second point
Int32 x3 // x position of the third point
Int32 y3 // y position of the third point
{r, g, b, a} color // color for the triangle
Boolean filled // (optional) Draw a filled triangle (true) or an outline (false, default)
Void Draw.circle(x, y, radius, color, filled);
// Draw a circle
Int32 x // x position of the center
Int32 y // y position of the center
Double radius // radius of the circle (distance from center to edge)
{r, g, b, a} color // color for the triangle
Boolean filled // (optional) Draw a filled circle (true) or an outline (false, default)
Void Draw.line(x1, y1, x2, y2, color, colorEnd);
// Draw a 2d line, with an optional gradient.
Int32 x1 // starting x position
Int32 y1 // starting y position
Int32 x2 // ending x position
Int32 y2 // ending y position
{r, g, b, a} color // line color
{r, g, b, a} colorEnd // (optional) line end color. if specified, will blend between the two colors along the line.
Void Draw.line3d(start, end, color, colorEnd);
// Draw a 3d line!
{x, y, z} start // start position
{x, y, z} end // end position
{r, g, b, a} color // line color
{r, g, b, a} colorEnd // (optional) line end color. if specified, will blend between the two colors along the line.
{x, y} Draw.worldToScreenPoint(position);
// Transform a point from world position to screen position.
{x, y, z} position // World position to transform
Void Draw.text(text, x, y, color);
// Draw a line of text.
String text // the text content to draw
Int32 x // x position of the text
Int32 y // x position of the text
{r, g, b, a} color // text color
Void Draw.textStyled(text, x, y);
// Draw a line of text with styling options
String text // the text to draw. $b for bold, $w for wavey, $s for drop shadow, $c for color, 0-F (e.g $c5hello $cAthere), $n to reset styling
Int32 x // x position of the text
Int32 y // x position of the text
Void Draw.wireframe(modelPath, position, rotation, color, backfaceCulling, drawDepth, filled);
// Draw a 3D wireframe.
String modelPath // Path of the model to draw
{x, y, z} position // Position to draw at
{x, y, z} rotation // Rotation in euler angles
{r, g, b, a} color // Color of the wireframe
Boolean backfaceCulling // (optional) Whether to skip triangles that face away from the camera (default: false)
Boolean drawDepth // (optional) Whether to render depth on the lines (default: false)
Boolean filled // (optional) Whether to draw the triangles filled (default: false)
Void Draw.model(modelPath, position, rotation, shaderPath, parameters);
// Draw a 3D model, optionally with a specified shader and parameters to use.
String modelPath // Path of the model to draw
{x, y, z} position // Position to draw at
{x, y, z} rotation // Rotation in euler angles
String shaderPath // (optional) Path of the shader to use (without extension)
ObjectInstance parameters // (optional) Object of key/value pairs to send to the shader
Void Draw.colorBuffer(colors, x, y, width);
// Draw a color buffer.
{r, g, b, a}[] colors // color array defining the image
Int32 x // x position to draw at
Int32 y // y position to draw at
Int32 width // width of the image
Void Draw.startBuffer(width, height);
// Start drawing to a pixel buffer instead of the screen. Call with Draw.endBuffer();
Int32 width // Width of the new buffer to draw to
Int32 height // Height of the new buffer to draw to
String Draw.endBuffer();
// Finish drawing to a pixel buffer and return a reference to the new texture.
Void Draw.texture(texturePath, x, y, rectangle, transformation);
// Draw a part of an image to the software canvas, with transformations
String texturePath // path to the image asset
Int32 x // x position of the image
Int32 y // x position of the image
{ x, y, w, h } rectangle // (optional) rectangle defining the portion of the image to draw
{ originX, originY, rotation, scaleX, scaleY, alpha } transformation // (optional) scaling, rotation and origin properties
Void Draw.setCamera(position, rotation);
// Set the 3d camera position and rotation
{x, y, z} position // position to set the camera to
{x, y, z} rotation // rotation to set the camera to, in euler angles
Void Draw.setFOV(fov);
// Set the field of view of the camera
Double fov // field of view
{forward, up, right} Draw.getCameraTransform();
// Get the 3d camera transformation
Void Draw.setBlendMode(blendMode);
// Set the blending mode for future draw operations. normal, noise, add
String blendMode //
Int32 Draw.fontHeight;
// Height, in pixels, of the currently loaded font.
Int32 Draw.fontWidth;
// Width, in pixels, of the currently loaded font.
Int32 Draw.screenWidth;
// Width, in pixels, of the screen resolution.
Int32 Draw.screenHeight;
// Height, in pixels, of the screen resolution.
Engine
Functions for engine-level functionality.
Void Engine.reset();
// Unload all assets and reset the engine.
Void Engine.setResetHotkey(keyCode);
// Set a global hotkey for resetting the engine, default F2.
Int32 keyCode // The keycode to set the hotkey to. Check Key documentation for options.
Void Engine.reloadShaders();
// Reload all shaders without resetting the engine.
Void Engine.quit();
// Quit the game.
Void Engine.redraw();
// Force a render mid-frame.
Void Engine.preload(path);
// Preload an asset.
String path // Path to the asset, asset type is determined by the extension
Void Engine.slowDrawFrame(frameSkip);
// Draw the next frame pixel by pixel
Int32 frameSkip // How many pixels to draw per frame of slow draw
Void Engine.toggleOverdraw();
// Toggle overdraw debug visualisation. Brighter pixels are being drawn more times
Void Engine.setMouseVisible(visible);
// Show or hide the mouse cursor
Boolean visible // true: show mouse, false: hide mouse
Void Engine.setResolution(width, height, scale);
// Set the screen resolution
Int32 width // sometimes i don't know what to write in here cause the variable name says everything already
Int32 height // i do'nt think it a PROBLEM to have a redundant description but its difficult to write them
Int32 scale // integer scaling for the screen
Double Engine.getTime();
// Return current system time.
Void Engine.setTargetFPS(fps);
// Set target maximum FPS.
Int32 fps //
Double Engine.timescale;
// Global game speed modifier. 1.0 = Default. 0.5 = half speed
Gamepad
A list of gamepad values for use with Input.getGamepadButton etc
Int32 Gamepad.up;
// DPad up
Int32 Gamepad.down;
// DPad down
Int32 Gamepad.left;
// DPad left
Int32 Gamepad.right;
// DPad right
Int32 Gamepad.y;
// Xbox: Y
Int32 Gamepad.a;
// Xbox: A
Int32 Gamepad.x;
// Xbox: X
Int32 Gamepad.b;
// Xbox: B
Int32 Gamepad.triangle;
// PlayStation: △
Int32 Gamepad.square;
// PlayStation: □
Int32 Gamepad.cross;
// PlayStation: X
Int32 Gamepad.circle;
// PlayStation: ○
Int32 Gamepad.leftbumper;
// Left bumper
Int32 Gamepad.rightbumper;
// Left bumper
Int32 Gamepad.lefttrigger;
// Left bumper
Int32 Gamepad.righttrigger;
// Left bumper
Int32 Gamepad.select;
// Select
Int32 Gamepad.start;
// Start
Int32 Gamepad.leftthumbstick;
// Left thumbstick
Int32 Gamepad.rightthumbstick;
// Right thumbstick
Input
Is the player doing anything? well now u can find out
Void Input.lockMouse();
// Lock the mouse and hide it
Void Input.unlockMouse();
// Unlock the mouse and show it
Boolean Input.getKey(key);
// Check if a key is held
Int32 key // key code to test (see keycodes.js)
Boolean Input.getKeyDown(key);
// Check if a key has been pressed this frame
Int32 key // key code to test (see keycodes.js)
Boolean Input.getKeyUp(key);
// Check if a key has been released this frame
Int32 key // key code to test (see keycodes.js)
Boolean Input.getGamepadAvailable(gamepad);
// Check if a gamepad is available for use
Int32 gamepad // gamepad index
String Input.getGamepadName(gamepad);
// Internal gamepad name
Int32 gamepad // gamepad index
Double Input.getLeftThumbstickX(gamepad);
// Left thumbstick X axis value [-1...1]
Int32 gamepad // gamepad index
Double Input.getLeftThumbstickY(gamepad);
// Left thumbstick Y axis value [-1...1]
Int32 gamepad // gamepad index
Double Input.getRightThumbstickX(gamepad);
// Right thumbstick X axis value [-1...1]
Int32 gamepad // gamepad index
Double Input.getRightThumbstickY(gamepad);
// Left thumbstick X axis value [-1...1]
Int32 gamepad // gamepad index
Double Input.getLeftTrigger(gamepad);
// Left trigger value [0...1]
Int32 gamepad // gamepad index
Double Input.getRightTrigger(gamepad);
// Left trigger value [0...1]
Int32 gamepad // gamepad index
Boolean Input.getGamepadButton(gamepad, button);
// Check if a gamepad button is held
Int32 gamepad // gamepad index
Int32 button // button code to test
Boolean Input.getGamepadButtonDown(gamepad, button);
// Check if a gamepad button has been pressed this frame
Int32 gamepad // gamepad index
Int32 button // button code to test
Boolean Input.getGamepadButtonUp(gamepad, button);
// Check if a gamepad button has been released this frame
Int32 gamepad // gamepad index
Int32 button // button code to test
Int32 Input.mouseX;
// X position of the mouse on the screen
Int32 Input.mouseY;
// Y position of the mouse on the screen
Boolean Input.mouseLeft;
// Whether the left mouse button is currently pressed.
Boolean Input.mouseLeftDown;
// Whether the left mouse button was pressed on this frame.
Boolean Input.mouseLeftUp;
// Whether the left mouse button was released on this frame.
Boolean Input.mouseRight;
// Whether the right mouse button is currently pressed.
Boolean Input.mouseRightDown;
// Whether the right mouse button was pressed on this frame.
Boolean Input.mouseRightUp;
// Whether the right mouse button was released on this frame.
Double Input.mouseWheel;
// How much has the mousewheel been moved this frame.
String Input.inputString;
// Alpha-numeric characters that have been typed this frame.
Boolean Input.anyKeyDown;
// Whether any key has been pressed this frame.
Key
All the available keyboard inputs you can check with Input.getKeyDown() etc.
Int32 Key.up;
// up
Int32 Key.down;
// down
Int32 Key.left;
// left
Int32 Key.right;
// right
Int32 Key.a;
// a
Int32 Key.b;
// b
Int32 Key.c;
// c
Int32 Key.d;
// d
Int32 Key.e;
// e
Int32 Key.f;
// f
Int32 Key.g;
// g
Int32 Key.h;
// h
Int32 Key.i;
// i
Int32 Key.j;
// j
Int32 Key.k;
// k
Int32 Key.l;
// l
Int32 Key.m;
// m
Int32 Key.n;
// n
Int32 Key.o;
// o
Int32 Key.p;
// p
Int32 Key.q;
// q
Int32 Key.r;
// r
Int32 Key.s;
// s
Int32 Key.t;
// t
Int32 Key.u;
// u
Int32 Key.v;
// v
Int32 Key.w;
// w
Int32 Key.x;
// x
Int32 Key.y;
// y
Int32 Key.z;
// z
Int32 Key.key0;
// key0
Int32 Key.key1;
// key1
Int32 Key.key2;
// key2
Int32 Key.key3;
// key3
Int32 Key.key4;
// key4
Int32 Key.key5;
// key5
Int32 Key.key6;
// key6
Int32 Key.key7;
// key7
Int32 Key.key8;
// key8
Int32 Key.key9;
// key9
Int32 Key.f1;
// f1
Int32 Key.f2;
// f2
Int32 Key.f3;
// f3
Int32 Key.f4;
// f4
Int32 Key.f5;
// f5
Int32 Key.f6;
// f6
Int32 Key.f7;
// f7
Int32 Key.f8;
// f8
Int32 Key.f9;
// f9
Int32 Key.f10;
// f10
Int32 Key.f11;
// f11
Int32 Key.f12;
// f12
Int32 Key.escape;
// escape
Int32 Key.return;
// return
Int32 Key.backspace;
// backspace
Int32 Key.tab;
// tab
Int32 Key.space;
// space
Int32 Key.leftbracket;
// leftbracket
Int32 Key.rightbracket;
// rightbracket
Int32 Key.printscreen;
// printscreen
Int32 Key.scrollock;
// scrollock
Int32 Key.pause;
// pause
Int32 Key.insert;
// insert
Int32 Key.home;
// home
Int32 Key.pageup;
// pageup
Int32 Key.delete;
// delete
Int32 Key.end;
// end
Int32 Key.pagedown;
// pagedown
Int32 Key.leftcontrol;
// leftcontrol
Int32 Key.rightcontrol;
// rightcontrol
Int32 Key.leftalt;
// leftalt
Int32 Key.rightalt;
// rightalt
Int32 Key.leftshift;
// leftshift
Int32 Key.rightshift;
// rightshift
Physics
Collision related functions
{hit, distance, position, normal} Physics.getCollisionRayGround(ray, height);
// Cast a ray against the floor plane at the specified height
{position, direction} ray // Ray to cast
Double height // Height of the floor plane
{position, direction} Physics.screenPointToRay(x, y);
// Create a ray from the screen position and return it
Int32 x // Screen X position to start the ray
Int32 y // Screen Y position to start the ray
{hit, distance, position, normal} Physics.getCollisionRayModel(ray, position, rotation, modelPath);
// Cast a ray against a model at a specified position and rotation
{position, direction} ray // Ray to cast against the model
{x, y, z} position // Position of the model
{x, y, z} rotation // Rotation of the model in euler angles
String modelPath // Path of the model to cast against
{hit, distance, position, normal} Physics.getCollisionRayPlane(ray, plane);
// Cast a ray against a plane
{position, direction} ray // Ray to cast against the plane
{position: {x, y, z}, normal: {x, y, z}} plane // Position and normal of the plane
Texture
The object returned by Assets.getTexture(path). Can be used to modify existing assets.
{r, g, b, a}[] Texture.getPixels();
// Get an array of pixels for the image
Void Texture.setPixels(colors);
// Set the pixels in the texture. Array length must be width * height.
{r, g, b, a}[] colors // Color array defining the new pixels. Laid out horizontally, so the first N pixels are like. the top row
Void Texture.startBuffer();
// Start drawing to this texture instead of the screen. If you don't call endBuffer() afterwards things will break
Void Texture.endBuffer();
// Stop drawing to the texture and update it
Void Texture.save(path);
// Save the texture to a file
String path // Path to save the texture to. i think you can pick the format but best stick to .png
String Texture.assetID;
// the asset path for the texture object. use this to draw it