API Reference

Goodluck includes a versatile collection of components and systems that can help you build your game.

Core Components

animate_sprite

The AnimateSprite component cycles through spritesheet tiles.

animate

The Animate component is used to animate the transform of the entity over time.

audio_listener

The transform of the entity with the AudioListener component will be used to set the position and orientation of game.Audio's listener.

audio_source

The AudioSource component is used to make entities play back audio. The sound data is defined by the AudioClip interface.

callback

A utility mixin which runs arbitrary logic when an entity is created.

camera

The Camera component makes the rendering system render the scene from the vantage point of the entity.

camera2d

The Camera2D component makes the rendering system render the scene from the vantage point of the entity.

children

The Children component is used to group entities together under a common parent.

collide

The Collide component allows detecting AABB collisions between entities.

collide2d

The Collide2D component allows detecting AABB collisions between entities.

control_always

Stores movement, rotation, and animation that will be applied to the entity every frame by sys_move and sys_animate, respectively.

control_always2d

Stores movement and rotation that will be applied to the entity every frame by sys_move_2d.

control_player

Make the entity controllable by the player. Suitable for first-person and third-person 3D games, as well as some camera control schemes.

disable

A utility mixin which disables a component mask when an entity is created.

draw

The Draw component allows drawing 2D primitives like text and rectangles.

emit_particles

The EmitParticles component makes the entity emit particles.

follow

The Follow component allows an entity to follow another entity. Only the position is followed, not the rotation.

lifespan

The Lifespan component allows the entity to autodestruct after a certain time. Upon destruction, the entity can emit an Action.

light

The Light component allows an entity to emit light.

local_transform2d

The LocalTransform2D component allows the entity to be positioned in 2D space.

look_at

The LookAt component allows an entity to look at another entity.

mimic

The Mimic component allows an entity to mimic another entity, i.e. match the target entity's position and rotation with a small lag.

move

The Move component allows the entity to move.

move2d

The Move2D component allows the entity to move in 2D space.

named

The Name component stores a name for the entity.

render

The Render component allows the entity to be rendered.

render2d

The Render2D component allows an entity to be rendered in 2D space.

rigid_body

The RigidBody component allows the entity to collide and interact with other rigid bodies

rigid_body2d

The RigidBody2D component allows the entity to collide and interact with other rigid bodies

shake

The Shake component allows the entity to change its position randomly every frame.

spatial_node2d

The SpatialNode2D component allows the entity to be part of the 2D scene graph.

spawn

The Spawn component allows the entity to spawn other entities.

task

The Task component is used to schedule tasks to be executed at a later time.

toggle

The Toggle component allows to periodically enable and disable other components on the entity.

transform

The Transform component stores the entity's position, rotation and scale in 3D space, as well as the entity's parent.

trigger

The Trigger component allows the entity's collider to trigger Actions.

Core Systems

sys_animate

Animate transforms of entities (position, rotation, scale) over time.

sys_audio_listener

Update the position and orientation of game.Audio's listener.

sys_audio_source

Play audio clips from entities with AudioSource.

sys_camera_xr

Update the PV matrix of the WebXR camera.

sys_camera

Update the PV matrix of the camera.

sys_camera2d

Update the PV matrix of the camera used for 2D rendering.

sys_collide

Detect collisions between static and dynamic colliders.

sys_collide2d

Detect collisions between static and dynamic colliders.

sys_control_always

Update the entity's Move and Animate components every frame.

sys_control_always2d

Update the entity's Move2D component every frame.

sys_control_keyboard

Handle keyboard input.

sys_control_mouse_drag

Handle mouse input when dragging with one of the buttons pressed. Good for cameras overlooking the scene.

sys_control_mouse_move

Handle mouse input when the mouse is moving without any buttons pressed. Good for FPS and TPS camera controls.

sys_control_touch_drag

Handle touch input when dragging with one finger. Good for cameras overlooking the scene.

sys_control_touch_move

Handle touch input using the "invisible joystick" approach. Good for FPS and TPS camera controls.

sys_control_xbox

Handle gamepad input.

sys_debug

Render colored wireframes around colliders and invisible entities.

sys_draw

Draw 2D primitives in the 3D scene using the Context2D API.

sys_draw2d

Draw 2D primitives in the 2D scene using the Context2D API.

sys_follow

Update the entity's position to follow another entity.

sys_lifespan

Autodestruct entities after a given time.

sys_light

Collect the lights in the scene and update the array of light positions and details to be passed to shaders in sys_render_forward.

sys_look_at

Update the entity's position to look at another entity.

sys_mimic

Update the entity's position and rotation to mimic another entity.

sys_move

Move and rotate entities.

sys_move2d

Move and rotate entities.

sys_particles

Update the instance arrays of particle emitters, to be passed to the shaders.

sys_physics_integrate

The first step of the physics simulation: integrate the rigid body's acceleration and velocity, and update the entity's transform.

sys_physics_kinematic

Derive the velocity of kinematic rigid bodies from the change in their position.

sys_physics_resolve

The second step of the physics simulation: resolve the collisions between rigid bodies.

sys_physics2d_integrate

The first step of the physics simulation: integrate the rigid body's acceleration and velocity, and update the entity's transform.

sys_physics2d_resolve

The second step of the physics simulation: resolve the collisions between rigid bodies.

sys_poll

Complete tasks whose ready condition has been satisifed.

sys_render_deferred

Render the world using the deferred rendering pipeline: the g-buffer pass.

sys_render_depth

Render the world to depth render targets.

sys_render_forward

Render the world using the forward rendering pipeline.

sys_render_shading

Render the world using the deferred rendering pipeline: the shading pass.

sys_render_xr

Render the world using an XR camera.

sys_render2d_animate

Animate sprites (WIP).

sys_render2d

Render all sprites in the world using the WebGL renderer.

sys_resize

Resize the inner resolution of canvases when the browser's window is resized, resize render-to-texture targets, and update the projection matrices of cameras in the scene.

sys_resize2d

Resize the inner resolution of canvases when the browser's window is resized, and update the projection matrices of cameras in the scene.

sys_shake

Shake entities randomly.

sys_shake2d

Shake entities randomly.

sys_spawn

Instantiate blueprints into the world periodically. Spawned entities inherit the spawner's position and rotation.

sys_spawn2d

Instantiate blueprints into the world periodically. Spawned entities inherit the spawner's position and rotation.

sys_toggle

Enable and disable the entity's other components periodically.

sys_transform

Apply changes to position, rotation, and scale to the entities' World transformation matrix, taking into account transforms of parents.

sys_transform2d

Apply changes to position, rotation, and scale, and update the instance array to be used by the shader.

sys_trigger

Emit an Action when another entity collides with this entity.

sys_trigger2d

Emit an Action when another entity collides with this entity.

sys_ui

Render the UI.

Libraries

aabb
aabb2d
audio
color
easing
framebuffer
game
html
input
load
mat2d
mat4
material
math
mesh
navmesh
number
pathfind
projection
projection2d
quat
random
raycast
texture
vec2
vec3
vec4
webgl
world

Utilities

tiled_tmj2map

Convert Tiled's JSON map representation to a TypeScript source file, which can then be imported and used by the tiled.ts module to instantiate a map.

tiled_tsj2atlas

Convert a Tiled tileset JSON file to an atlas definition in TypeScript.