scmJS docs

Screen

trigscript/screen is a grid of pixels shown on the map as units, so the minimap shows the picture: a game of Snake or Tetris played on the minimap, a score in big digits.

import { Screen, sprite } from "trigscript/screen";

const SHIP = sprite([".1.", "111", "1.1"]);

program(async () => {
  const screen = new Screen(4, 4, 24, 16);   // 24 × 16 pixels, its top left on tile (4, 4)
  screen.reveal(P1);
  let x = 10;
  let score = 0;
  while (true) {
    if (keyHeld(P1, "Left")) x = Math.max(x - 1, 0);
    if (keyHeld(P1, "Right")) x = Math.min(x + 1, 21);
    screen.clear();
    screen.rect(0, 15, 24, 1, 5);            // the ground, in colour 5
    screen.blit(SHIP, x, 12);
    screen.number(score, 1, 1, 2);           // digits 3 × 5 pixels, in colour 2
    screen.present();
    score += 1;
    await nextFrame();
  }
});

A pixel is 0 (empty) or a colour from 1 to 7. Drawing changes the grid, and present() shows it: each pixel is a unit on the map, two tiles across, owned by the player whose colour it is. Only the pixels that changed since the last present() are made or taken away, so a still picture costs nothing to show. Draw through the methods; a pixel written into the grid directly is not seen.

What the map needs.

Name What it does
new Screen(x, y, width, height, look?) A screen of width × height pixels (2 048 at most), its top left on tile (x, y). look is "dots" (the default) or "solid".
clear(color?), set(x, y, color), get(x, y) Fill it, set one pixel, read one.
rect(x, y, width, height, color), line(x0, y0, x1, y1, color) A filled rectangle; a line, both ends drawn.
sprite(rows), blit(sprite, x, y) A picture from rows of text ("1" … "7", anything else see-through), and drawing it.
number(n, x, y, color) A whole number's digits, 3 × 5 pixels each.
reveal(player) Let a player see the screen.
present() Show what was drawn.
<ScreenView screen width height /> The same grid in a player's text area, a square a pixel, for a ui.lines view.