# Bring a GameMaker game

For a GameMaker game that already ships as an HTML5 export on other web game portals. You replace the other portal's extension with the ZokoGames one and move your ad, save and score calls to the `zoko_*` functions. The full reference is the [GameMaker engine page](https://docs.zokogames.com/engines/gamemaker). The overall route is in [bring your game](https://docs.zokogames.com/porting/overview).

## 1. Export settings

Set up the `ZokoGames` extension as in [GameMaker: install](https://docs.zokogames.com/engines/gamemaker#install): `zokogames.js` ticked for HTML5 only, `zokogames_sim.gml` for every other platform, each function declared. Then:

| Setting | On ZokoGames |
| --- | --- |
| SDK script tag | Add `<script src="https://sdk.zokogames.com/zokogames-sdk-v1.js"></script>` to the game's `index.html` through the HTML5 game options, and remove the other portal's tag. Without it every call fails with `sdkNotLoaded`. |
| Output | Export HTML5 to a clean folder; zip its contents so `index.html` is at the archive root. |
| Pre-compression | None. GameMaker requests plain file names. |
| Scaling | "Keep aspect ratio" or "Full scale", so the game fits a frame that changes with fullscreen and rotation. |
| Loading bar | If you report loading to the portal yourself, turn the built-in bar off. |

Details: [HTML5 export settings that matter](https://docs.zokogames.com/engines/gamemaker#html5-export-settings-that-matter).

## 2. Replace the platform calls

Remove the other portal's extension and its calls first. Asynchronous `zoko_*` functions return a request id at once; the answer arrives in the **Async - Social** event with `async_load[? "type"] == "zoko"` ([how calls work](https://docs.zokogames.com/engines/gamemaker#how-calls-work)). Use one **persistent** controller object for them.

| Your game does | With the extension |
| --- | --- |
| Start the SDK | `zoko_init()` once, from the controller; wait for its `response` event. |
| Loading finished | `zoko_game_loading_stop()` once the first room can be played (optionally `zoko_game_loading_start()` and `zoko_game_loading_progress(p)` before it). The extension does not send these on its own. |
| Gameplay start and stop | `zoko_game_gameplay_start()` and `zoko_game_gameplay_stop()`. |
| Midgame (interstitial) or rewarded ad | `zoko_ad_request_ad("midgame")` or `"rewarded"`. Pause on the `ad_started` event; resume on `ad_finished` and on `ad_error`. Grant a reward only on `ad_finished`. |
| Mute | The `settings_changed` event carries `{ disableChat, muteAudio }`. |
| Cloud save | `zoko_data_set_item(key, value)`, `zoko_data_get_item(key)` (`""` when missing), `zoko_data_has_key(key)`. |
| Leaderboard score | `zoko_user_submit_score(encrypted_score, score)` for a signed-in player, on a board created in the console. No wrapper builds the encrypted payload; see [leaderboards](https://docs.zokogames.com/sdk/leaderboards#client-submission). |
| Purchases | `zoko_store_get_catalog_items(limit, offset)`, `zoko_store_buy_item(sku)`, `zoko_store_consume_item(sku, qty)`. Purchases are test purchases for now ([purchases](https://docs.zokogames.com/sdk/purchases)). |
| Sign-in prompt, player | `zoko_user_show_auth_prompt()`, `zoko_user_get_user()`. |

A complete controller is in [a working controller](https://docs.zokogames.com/engines/gamemaker#a-working-controller), and every function in [functions](https://docs.zokogames.com/engines/gamemaker#functions). Structured results are JSON text: wrap them in `json_parse`.

The [compatibility shim](https://docs.zokogames.com/guides/migrating#two-ways-to-port) is for JavaScript call sites only; GML calls move to the `zoko_*` functions.

## 3. Build size and mobile

- Budget: 1,500 files, 250 MB unpacked, about 50 MB initial download (20 MB for mobile), estimated from uncompressed sizes.
- Use texture groups so only the first room's textures are in the initial download; use OGG audio and stream music.
- The HTML5 target is single-threaded: keep Step events cheap while ads show and memory modest for phones.
- Start music from a "click to play" room. See [mobile](https://docs.zokogames.com/guides/mobile).

## 4. Test before you submit

1. **On Windows, macOS or Linux** the GML simulator answers one tick later with the same events. Edit `global.zoko_sim_config` before `zoko_init()` to force ad errors, a logged-out player or a disabled SDK.
2. **The HTML5 export on `localhost`** runs the SDK's local mode, which also enforces the three-minute midgame cooldown the simulator skips. See [GameMaker: test locally](https://docs.zokogames.com/engines/gamemaker#test-locally).
3. **Upload the zip** and open the game's **Preview and QA** tab in the developer console to run it in the portal frame with ads on ([build preview](https://docs.zokogames.com/getting-started/local-testing#the-build-preview-in-the-console)).

## Checklist

- [ ] Extension set up for HTML5 and the simulator; the other portal's extension removed.
- [ ] SDK script tag in `index.html`; the other portal's tag removed.
- [ ] `zoko_init()` first, from a persistent controller; the game plays when the SDK is `disabled`.
- [ ] Gameplay start and stop at the right moments.
- [ ] Ads resume on `ad_finished` and `ad_error`; rewards only on finish.
- [ ] Saves through `zoko_data_*`; scores on a board created in the console.
- [ ] Other portal's logos, links and sitelock removed.
- [ ] Tested on `localhost` and in **Preview and QA**.

## Next

- Full reference: [GameMaker](https://docs.zokogames.com/engines/gamemaker).
- Before upload: [build validation](https://docs.zokogames.com/requirements/build-validation) and the [launch checklist](https://docs.zokogames.com/requirements/checklist).
- Upload and publish: [submission walkthrough](https://docs.zokogames.com/getting-started/submission-walkthrough).
