Engine.js needs nothing more than a browser and a copy of the repository to get running. In the next few steps you’ll have the editor open, a physics-enabled square falling under gravity, and a live simulation running — all without installing a single dependency or starting a server.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/OmarMtya/engine.js/llms.txt
Use this file to discover all available pages before exploring further.
Clone the repository and open the editor
Clone the Engine.js repository from GitHub, then open After cloning, open
index.html directly in your browser:index.html by double-clicking it in your file manager, or by navigating to it in your browser with File → Open File. No local server is needed — the editor loads immediately. You’ll see the Engine.js header with a green Play button at the top and the configuration toolbar at the bottom.The
engine/ directory — which contains engine/index.js, the ES module that exposes the $g namespace — is listed in .gitignore and is not included in the cloned repository. You must obtain and place the engine/ folder alongside index.html before opening the editor. Without it, $g will be undefined and the editor will not function.Add a square object
Click the square icon (fas fa-square) on the right side of the configuration toolbar at the bottom of the editor.This runs the following logic internally:A 20×20 black square appears on the canvas at position (100, 100), and a new entry is added to the Hierarchy panel on the left. The object receives an auto-generated name and a unique
id automatically.Add a circle object
Click the circle icon (fas fa-circle) in the configuration toolbar.This internally creates:A circle with radius 10 appears on the canvas at (100, 100). It is listed separately in the Hierarchy panel. Both objects now coexist in the
$g.figuras array.Select an object and configure its properties
Click any entry in the Hierarchy panel to select it. The Attributes panel appears on the right side of the editor with the following editable fields:
Try changing the fill color of the square to a red hue using the color picker. The canvas re-renders immediately on every change. You can also reorder objects using the ↑ and ↓ arrow buttons in the Attributes panel header, or delete the selected object with the trash icon.
| Field | Description |
|---|---|
| Name | Free-text label shown in the Hierarchy panel |
| Type | Dropdown — cuadrado, circulo, or imagen |
| X / Y | Canvas position in pixels |
| Width / Height | Dimensions for squares and images (anchura / altura) |
| Radius | Radius for circles (radio) |
| Fill | Color picker for the object’s fill color (relleno) |
Enable physics on the square
With the square selected in the Hierarchy panel, locate the Rigid (The
Rígido) section at the top of the Attributes panel.- Check the Rigid checkbox — this attaches a
$g.Rigido()instance to the object and reveals the physics sub-fields. - Set Gravity (
Gravedad) to a value such as0.5— this becomes therigido.valorapplied each animation frame. - Optionally, ensure Collision (
Colisión) is checked to allow the object to interact with scene boundaries.
$g API:$g.Rigido() constructor sets the default gravity value. Adjust figura.rigido.valor to increase or decrease the gravitational pull.Collision-based sound triggers (
colision and colisionInversa) on a $g.Sonido instance require rigido to be enabled on the object. If Rigid is not active, those audio triggers will not fire.Press Play and run the simulation
Click the green Play button in the header. The following happens:
- The engine sets
animando = trueand calls$g.Animar(), starting the requestAnimationFrame loop. - The Attributes panel is hidden so the canvas has full focus.
- Click selection on canvas objects is disabled during play.
- If a global background audio track was loaded, it begins playing automatically.
$g.DetenerAnimacion(), redraws the final static frame with $g.Dibujar(), and restores the Hierarchy panel and click-selection so you can continue editing.