Fork me on GitHub

WGLT - WebGL Terminal

What is it?

WGLT is a JavaScript/TypeScript library for creating ASCII games in the browser.

WGLT is absurdly overoptimized for performance, using WebGL for minimal CPU.

WGLT is modelled after libtcod and rot.js.

Install

Add dependency:

npm i -D wglt

Import library:

import { Colors, Terminal } from 'wglt';

Usage

Use it:

import { Colors, Terminal } from 'wglt';

const term = new Terminal(document.querySelector('canvas'), 80, 45);
term.fillRect(0, 0, 80, 45, 0, Colors.YELLOW, Colors.DARK_BLUE);

let x = 10;
let y = 10;

term.update = () => {
  const moveKey = term.getMovementKey();
  if (moveKey) {
    x += moveKey.x;
    y += moveKey.y;
  }

  term.clear();
  term.drawString(1, 1, 'Hello world!');
  term.drawString(1, 3, 'Use arrow keys to move');
  term.drawString(x, y, '@');
};

Examples