Options
All
  • Public
  • Public/Protected
  • All
Menu

@agogpixel/phaser3-glyph-plugin

agogpixel/phaser3-glyph-plugin

Build & Test Coverage Version Downloads/week License

⚠️ INITIAL DEVELOPMENT ⚠️


Phaser 3 glyph plugin. Inspired by rot.js canvas-based ASCII display. Requires Phaser v3.22+.

💥 DEMOS

Getting Started

  1. Install the package:

    npm install --save @agogpixel/phaser3-glyph-plugin
    
  2. Extend a scene (TypeScript only) with the plugin mapped to the glyph property:

    import { GlyphPlugin } from '@agogpixel/phaser3-glyph-plugin';

    class MyScene extends GlyphPlugin.GlyphScene('glyph', class extends Phaser.Scene {}) {
    create() {
    const glyphmap = this.add.glyphmap(0, 0, 10, 10);

    for (let y = 0; y < glyphmap.heightInCells; ++y) {
    for (let x = 0; x < glyphmap.widthInCells; ++x) {
    if (!y || !x || y === glyphmap.heightInCells - 1 || x === glyphmap.widthInCells - 1) {
    glyphmap.draw(x, y, [['#', '#EEEEEEFE', '#4444']]);
    } else {
    glyphmap.draw(x, y, [['.', '#FFF']]);
    }
    }
    }

    const center = glyphmap.getCenter();
    this.cameras.main.centerOn(center.x, center.y);
    }
    }
  3. Add the plugin & extended scene to the game config:

    new Phaser.Game({
    // ...
    plugins: {
    global: [
    {
    key: 'GlyphPlugin',
    plugin: GlyphPlugin,
    mapping: 'glyph',
    start: true
    }
    ]
    },
    scene: [MyScene]
    // ...
    });

Usage

Under initial development. Please refer to the API docs & demos for usage examples.

Development

Live development with jest watch mode:

npm start

Live development with demos:

npm run demos

Lint files:

npm run lint      # Report issues.
npm run lint-fix # Fix issues.

Unit test & create coverage report in coverage/:

npm test

Build consumable .js, .js.map, & .d.ts files to dist/; prepare for further packaging:

npm run build

Smoke test build:

npm run smoke-test

Create package tarball from dist/:

npm run create-tarball               # Development stream.
npm run create-tarball -- --release # Release stream.

Publish package tarball to registry (some assembly required):

npm run publish-tarball -- NPM
npm run publish-tarball -- GitHub

Package Distribution

Tag for stable release with highest version: latest

Development release tag (tracks main branch): next

Additional distribution tags include:

Distribution Release Pre-Release
Major versions with highest minor, patch (and possibly pre-release) version. vX~latest vX~next
Major, minor versions with highest patch (and possibly pre-release) version. vX.Y~latest vX.Y~next
Major, minor, patch versions - catch all for releases that don't match any of the above. vX.Y.Z~latest vX.Y.Z~next

License

Licensed under the MIT License.

Generated using TypeDoc