HypercasualGaming SDK
Engines

GameMaker

With the official HGSDK extension you call the SDK directly from GML, without writing JavaScript. It works when you export your game to HTML5.

📦
HGSDK_v1.yympsGameMaker extension · local package
⬇ Download extension

1. Import the extension

  1. Open your project and go to Tools → Import Local Package.
  2. Choose HGSDK_v1.yymps, click Add All and then Import.
  3. The HGSDK extension appears in the Asset Browser with these functions:
GML functionWhat it's for
hg_gameplay_start()Gameplay starts or continues.Required
hg_gameplay_stop()Gameplay stops: losing, pausing or going to the menu.Required
hg_send_score(score)Sends the score and, if the player is signed in, saves their high score. It doesn't stop gameplay. Only if your game has a score.Optional
hg_ad_break()Ad between runs. It returns nothing: the game is frozen during the ad and continues on its own.Optional
hg_ad_reward(name)Ad the player chooses to watch in exchange for something. The result arrives at the Asynchronous → Social event (see section 4).Optional

2. Call the functions from GML

// When gameplay starts
hg_gameplay_start();

// When the player loses: send the score (optional, a whole number) and stop
hg_send_score(score);
hg_gameplay_stop();

// Your pause menu
hg_gameplay_stop();  // when opening your pause menu
hg_gameplay_start(); // when closing it

3. Export to HTML5 and add the SDK

  1. Choose the HTML5 target and export with Create Executable, as a folder or as a .zip.
  2. Open the exported index.html and add the SDK line right before the game's script (the one in the html5game/ folder):
<script src="/sdk/v1/hg-sdk.js"></script>
<script type="text/javascript" src="html5game/YourGame.js"></script>

GameMaker generates index.html again on every export: repeat this step each time, or use your own index.html as an included file in the HTML5 options.

Make your rooms portrait (for example 720 × 1280) and, in Game Options → HTML5 → Graphics, choose Scaling: Keep aspect ratio so the game fits any screen.

4. Ads (optional)

Your game doesn't load ads by itself: it asks the website and the website shows them on top, freezing and muting the game meanwhile. There are two kinds: break (between runs) and reward (the player chooses to watch it in exchange for something in the game). Don't report that gameplay stops or continues because of an ad: the SDK freezes and resumes your game on its own.

// Ad between runs, never before the first one: the game stays frozen until it ends, just carry on
if (global.runs > 0) hg_ad_break();
global.runs++;
start_game();

// Ad the player chooses to watch
hg_ad_reward("revive");         // when they ask to revive
hg_ad_reward("double_coins");   // at another moment: to double their coins

// Asynchronous → Social event
if (ds_map_exists(async_load, "type") && async_load[? "type"] == "hg_ad") {
    var ok = async_load[? "rewarded"];   // 1 only if they watched it to the end
    switch (async_load[? "name"]) {      // the name you passed to hg_ad_reward
        case "revive":       if (ok) revive(); else game_over(); break;
        case "double_coins": if (ok) coins *= 2; break;
    }
}

In that event, async_load is a map with these keys:

A reward can come back without an ad at any moment (none available or ads switched off): your game has to keep working. And a reward never gives score — revives, continues, extra lives or skins are fine.

5. What you don't need to do

6. Test it

Upload the exported folder (or its .zip) in Upload game and tap 🧪 Test before submitting. More details in Test and publish.