16x23 Pixel Display Library

This library is intended for those interested in creating games and simulations programming at the pixel level using a virtual 16x23 led matrix display.

  • The sprite "16x23_library" implements the library code.

  • The sprite "your_code" is where you write your program. This sprite includes a very simple demo using the 5 library blocks available (see below).

Parameters:

  • bri: pixel brightness (-100 to 100).
  • col: pixel color (-2 to 200, -2 = off, -1 = white).
  • trans: transparent sprite (1 if transparent, 0 it not).
  • h: sprite/block height (rows).
  • m: sprite list index (0 to 25 for built-in sprites).
  • n: pixel number (0 to 367).
  • w: sprite/block width (columns).
  • x: pixel/block/sprite left column (0 to 22).
  • y: pixel/block/sprite top row (0 to 15).
  • bc: background color of the sprite (if not transparent).
  • bb: background brightness of the sprite (if not transparent).
  • x0: first sprite column plotted (1 to 4).
  • xn: sprite columns plotted (1 to 4).
  • v: if set to 1, the list "display" is used to select the color of each pixel in a block of pixels.

Variables:

  • display: a list to store the color of each pixel that will be used if a block of pixels is plotted with the parameter "v" set to 1.

Blocks:

  • init: create and show the display (call first).
  • plot_n (n, col, bri): plot a pixel given its number n.
  • plot_xy (x, y, col, bri): plot a pixel given its coordinates x and y.
  • plot_b (x, y, w, h, col, bri, v): plot a block of pixels.
  • plot_s (x, y, m, h, col, bri, trans, bc, bb , x0, xn): plot a sprite stored in the "_ sprites _" private list.

Built-in sprites (in order):

  • Hexadecimal digits (0 to F).
  • Decimal digits (0 to 9) with two columns (x0=3 and xn=2).

You can add your own sprites changing manually the "_ sprites _" private list. The rows must be encoded as a string of lowercase hexadecimal digits (as many digits as rows).

I will add examples of programs written using this library to my collection "16x23 Pixel Display". Your contribution to this collection would be most welcome.

I hope you will find this library useful.
Kind regards,
Javier (Mr. Piay)

Untitled

Oooh, that's nice! I love "fat pixel" setups. Thanks for sharing!

That's very beautiful. At the Scratch conference... last summer? Was it that recent?... in Bordeaux we saw a fat-pixel display covering an entire outside wall of a building that could be programmed over WiFi. That was fun!

Could I make a tiny suggestion about the code? You could avoid using all those global variables if, instead of BROADCAST, you communicated between the sprites this way:


(This particular code style depends on the fact that both sprites have same-name methods. If not, you could still do something equivalent, but a little more complicated.)

Thank you very much for your suggestion, I will definitely follow it! (I'm still discovering these awesome Snap features).

...

Done!, Yes, that makes a big difference. Thanks @bh