WebGame.Jp

For game creators

Add a score leaderboard to your game

Any game listed on WebGameJp can get a free online score leaderboard with the Score SDK. No server needed. Submitted scores also appear on the game page and leaderboard page on WebGameJp.

1. Load the SDK

Add one line to your game's HTML. For data-game-id, use the game ID shown on the edit screen under "My games" in the creator dashboard.

<script src="https://webgame.jp/sdk/v1.js" data-game-id="123"></script>

2. Send a score

Scores are integers of 0 or more. Names can be up to 20 characters. If you omit the name, the previous name or "Guest" is used.

// ゲームオーバーのときに呼ぶ
WebGameJp.submitScore(score, { name: playerName })
  .then(function (result) {
    // result.rank         … 何位か
    // result.totalPlayers … 参加人数
    // result.isPersonalBest … 自己ベストか
    showMessage(result.rank + '位 / ' + result.totalPlayers + '人');
  })
  .catch(function (error) {
    console.warn(error.message); // 送れなくてもゲームは続けられる
  });

3. Show the leaderboard

// 上位10件を取ってきて、ゲームの中に表示する
WebGameJp.getRanking().then(function (scores) {
  scores.forEach(function (row, i) {
    console.log((i + 1) + '位 ' + row.player_name + ' ' + row.score);
  });
});

// WebGameJp のランキングページを新しいタブで開く
WebGameJp.openRanking();

For Unity (WebGL)

Add the line from step 1 to your WebGL index.html and call the SDK from a .jslib file.

// Assets/Plugins/WebGameJp.jslib
mergeInto(LibraryManager.library, {
  SubmitScore: function (score) {
    window.WebGameJp && WebGameJp.submitScore(score);
  }
});

// C# 側
[DllImport("__Internal")] private static extern void SubmitScore(int score);

Good to know

← Submit your game