npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

disgame

v1.0.8

Published

A lightweight tile-based Discord game engine!

Downloads

11

Readme

Disgame

Disgame is an extremely lightweight Discord game engine. (Beta)

ezgif-2-42edb508961e

// ...
const wait = (ms: number) => new Promise((resolve, reject) => setTimeout(resolve, ms));

client.on("message", async (msg) => {
    // ... listen for command
    
        const gameMessage = await msg.channel.send(
            new Discord.MessageEmbed()
                .setTitle("Game")
                .setDescription("...") // The description will automatically be overwritten by Disgame to contain the game view
                .setFooter("")
        )

        const game = new Disgame({
            message: gameMessage, // the message disgam will "render" to. (If embed uses description; if message uses content)
            size: { // the emoji background tile size
                width: 10,
                height: 7
            },
            backgroundEmoji: "⬜" // the game background
        });

        // create tiles
        const appleTile = game.addTile(new Tile({ emoji: "🍎", position: { x: 0, y: 0 } }));
        const bananaTile = game.addTile(new Tile({ emoji: "🍌", position: { x: 3, y: 3 } }));
        const pearTile = game.addTile(new Tile({ emoji: "🍐", position: { x: 5, y: 5 } }));

        for (var i = 0; i < 4; i++) {
            // increment position of "appleTile" to move diagonally
            appleTile.position.x++;
            appleTile.position.y++;

            game.render(); // call render fuction to edit the message with the updated scene
            await wait(1000); // wait 1 second
        }

        game.removeTile(appleTile); // remove "appleTile" once its done
        game.render(); // render 
});

// ...

Table of Contents

  1. Overview
  2. Usage
    1. Base
    2. Tiles
  3. Examples
  4. Credits

Usage

Base

The base (Disgame) is the start to any game. It is used to render the view to a chosen message

 const game = new Disgame({
    message: gameMessage, // a created message (embed, plain, etc)
    size: { 
        width: 10,
        height: 7
    },
    backgroundEmoji: "⬜"
});

Disgame_Dimension

Options/Properties

| Optional | Name | Description | Default | | :------- | ----------------- | ------------------------------------------------------------ | ------------------------- | | ❌ | message | Discord.Message The message in which you want to render the game when render() is called. | | | ✅ | size | {width: number; height: number} The size of the canvas. | {width: 10, height: 10} | | ✅ | backgroundEmoji | `string The emoji used to fill the background. | ⬛ |

Methods

| Name | Description | Returns | | ------------------------ | ------------------------------------------------------------ | -------- | | render() | "Renders" the game view as text to the Discord message. (Should be called when you want to update a change on the screen) | void | | addTile(tile: Tile) | Adds a new tile object to the game. | tile | | removeTile(tile: Tile) | Removes a tile from the game. | void | | getTile(name: string) | Gets all tiles with the chosen name. | Tile[] |

Tiles

Tiles are emojis at certain positions on the game canvas. The can be added and remove from games using the respective game functions addTile(tile: Tile)/removeTile(tile: Tile). Tiles can also be found by calling getTile(name: string).

Disgame_Position

const game = new Disgame({
   message: gameMessage, // a created message (embed, plain, etc)
   size: { 
        width: 10,
        height: 7
    },
    backgroundEmoji: "⬜"
});

let bananaTile = game.addTile(new Tile({
    emoji: "🍌",
    position: {
        x: 3,
        y: 4
    }
}));

game.render();

Options/Properties

| Optional | Name | Description | Default | | -------- | ---------- | ------------------------------------------------------------ | -------------- | | ❌ | emoji | string The emoji used to display the tile | | | ✅ | name | name Used to get tiles by name using the getTile(tile: string) function. | | | ✅ | position | (IPosition) {x: number, y: number} The tile's position | {x: 0, y: 0} |

Examples

Moving Tile

Coming soon

Credits

Made by Badusername420