# Construct

Export Construct 3 projects to HTML5 and publish the folder to Wavedash.

Source: https://docs.wavedash.com/engines/construct

<GithubLink href="https://github.com/wvdsh/examples/tree/main/example-construct" />
<PlaytestLink href="https://wavedash.com/playtest/construct-example/4ce642c1-158f-4955-9a44-e2863b7ce4fe" />

Construct 3 exports directly to HTML5 with no additional tooling. The output is a self-contained folder of HTML, JS, and assets that runs in any browser.

## Export your game

1. Open **Menu → Project → Export**
2. Select **Web (HTML5)** as the export target
3. Choose `build/` as the destination folder
4. Extract the downloaded zip into `build/`

## SDK integration from Construct scripts

Wavedash injects `Wavedash` on the game's `window` before your code runs. Call it from a Construct script file (typically `main.js`) inside a `runOnStartup` handler. Use `beforeprojectstart` to hook into the earliest moment Construct guarantees the scene is set up:

```javascript
// scripts/main.js
runOnStartup(async (runtime) => {
  runtime.addEventListener("beforeprojectstart", async () => {
    const Wavedash = window.Wavedash;

    // Report early progress once the runtime is available.
    Wavedash.updateLoadProgressZeroToOne(0.3);

    // Your game logic here...
    Wavedash.updateLoadProgressZeroToOne(0.8);

    // Signal load complete, then reveal the game.
    Wavedash.updateLoadProgressZeroToOne(1);
    Wavedash.init({ debug: true });
  });
});
```

`Wavedash` is injected on `window` before any script in the export runs, so you can reach for `window.Wavedash` synchronously.

### Script file setup in the IDE

For your startup script to run, each script file in the Project panel needs an explicit **Purpose** (even `(none)` — leaving it unset silently breaks the export's script wiring):

1. Right-click the `Scripts` folder → **Add script file**, name it `main.js`
2. Select `main.js`, then in the **Properties** panel set **Purpose** to **Main** (there can only be one "main" script per project)
3. For every helper script (e.g. `pong.js`, `wavedash.js`) set **Purpose** to **(none)** — the main script will then `import` them via normal ES modules

## wavedash.toml

```toml
game_id = "YOUR_GAME_ID_HERE"
upload_dir = "./build"
```
