Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@webxdc/highscores

Package Overview
Dependencies
Maintainers
0
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@webxdc/highscores

Highscores API for webxdc apps

  • 5.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

Highscores

npm package CI code style: prettier

Library to facilitate the process of creating score-based webxdc games. It can handle multiple scoreboards at the same time.

Install

npm install @webxdc/highscores

Usage

Quick overview of the API:

import "@webxdc/highscores";

// always do this first, only use the API after init() finishes
await window.highscores.init();

// get current player's highscore
const score = window.highscores.getScore();
console.log(`your score: ${score}`);

// this will cause an announcement in chat only if it's a new highscore
window.highscores.setScore(score + 100);

const scoreboard = window.highscores.getHighScores();
scoreboard.forEach((player) => {
  console.log(`${player.pos}. ${player.name} - ${player.score}`);
});

The webxdc.js lib also needs to be included in your index.html:

<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width" />
    <script src="webxdc.js"></script>
    <script type="module">
      import "@webxdc/highscores";
      // you can use window.highscores here
    </script>
  </head>
  <body>
    ...
  </body>
</html>

Check dist/highscores.d.ts file for documentation of the available API.

For a full example check the example/index.html file.

Keywords

FAQs

Package last updated on 17 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc