HypercasualGaming SDK
The SDK is a small JavaScript file your HTML5 game loads to live inside the feed. The website shows your game, pauses it, handles its sound, keeps its high scores and shows ads on top of it — your game only has to say when gameplay starts and stops.
How your game lives in the feed
Players go from one game to the next in the feed. Your game:
- is shown in portrait, with the website's buttons around it (the like button, rankings, restart, sound, report…);
- runs in its own frame: it can't load anything from other websites, and it talks to the website only through the SDK;
- is loaded before the player reaches it and stays frozen while it isn't on screen, so switching games is instant.
What the SDK does for you
- Cover: you don't need to make a start screen. The SDK shows a cover with what you enter when you upload the game (logo, name, controls sentence and cover video, if you upload one) and “TAP TO PLAY”.
- Pause when switching games: it freezes
requestAnimationFrame, Web Audio and<audio>/<video>. Run your game loop withrequestAnimationFrame:setTimeoutandsetIntervalaren't frozen. - “Tap to continue”: if the player comes back in the middle of a run, they see the same pause screen as in every game.
- Feed gestures: outside gameplay, swiping, the mouse wheel or the ↑ ↓ arrows switch games, and your game doesn't receive that wheel or those arrows; Page Up and Page Down switch games at any time, even during gameplay; during gameplay, touches belong to your game.
- Sound and music: it applies the website's mute button and lets your music start as soon as the browser allows sound.
- High scores and rankings: if your game sends scores, the website keeps the best of each signed-in player and shows your game's rankings (today, this week and all time).
- Ads: if your game asks for them, the website shows them on top of it and freezes it meanwhile. Your game never loads an ad network.
- Statistics: views, runs, real play time and loading time, on your game's dashboard.
How it's integrated
The SDK requires three things, whatever your engine. The rest of the SDK is optional: use it only if your game needs it. Your game also has to meet the requirements.
| What | How | |
|---|---|---|
| Load the SDK before your game | <script src="/sdk/v1/hg-sdk.js"></script> | Required |
| Gameplay starts or continues | HGSDK.gameplayStart() | Required |
| Gameplay stops (the player loses, pauses or goes to the menu) | HGSDK.gameplayStop() | Required |
| Send the score, if your game has one | HGSDK.sendScore(score) | Optional |
| Ask for an ad, if you want to monetize | HGSDK.showAd({ type }) | Optional |
The automatic pause (when an ad is shown, when the player switches games or leaves the website…), the sound, the gestures and the cover work on their own: you don't have to program them. Your game can still have its own pause menu.
What “gameplay” means
Gameplay is the time the player is actually playing. Only then do touches belong to your game, play time counts and, if the player leaves, they'll find “Tap to continue” when they come back. In your menu or end screen, a swipe goes to another game.
Choose your engine
From your game to the feed
Before submitting your game, check the requirements and how to test and publish it. All the functions are in the reference.
HypercasualGaming