Sections of a PuzzleScript file

A puzzlescript file is divided into the following sections.

Objects

Here's where your in-game objects are all declared. The simplest way is to give something a name and a color.

OBJECTS
=======      
Player P
Blue
If you do this, the player will be a blue square.

You can specify a sprite as a 5x5 grid as follows:

Player P
PINK YELLOW #000000    
.222.
.000.
22122
.222.
.2.2.

Which gives you this wee fella:

Object Names

The first line is the name of the object, and aliases too if you like. So the extra P on the line is another name for the Player object (and you can have as many aliases as you like). This is convenient for creating single characters needed for putting objects into a level, but you can get the same result in the Legend section if you prefer.

Colors

The second line is a list of colors. The available color names are as follows, but the exact shade of color is set according to the palette setting in the prelude.

  • black
  • white
  • lightgray/grey
  • gray/grey
  • darkgray/grey
  • red
  • darkred
  • lightred
  • brown
  • darkbrown
  • lightbrown
  • orange
  • yellow
  • green
  • darkgreen
  • lightgreen
  • blue
  • lightblue
  • darkblue
  • purple
  • pink
  • transparent

See this Color Chart for a display of the colors in the default palette. You can change the palette if you like.

Or you can use hex codes if you prefer.

The Grid

The third and following lines are rows of numeric digits making up the sprite grid (or they can be omitted, and then you just get a square). The dots represent transparency, and the numbers 0..9 index the colors in the second line, for as many colors as there are.

In the simple case each line is sprite_size in length and there are sprite_size of them. This defaults to 5x5, but you can set it set to a different value in the prelude.

The sprite grid can be smaller or larger, and does not have to be square. It will be rendered with the bottom left-hand corner aligned with the tile. If it is larger, it will overflow and hide tiles above and to the right. You can use control this, see CollisionLayers.

Transforms

Following the sprite grid are one or more lines of object transforms. The transforms are executed in order, left to right, and modify the sprite grid as they do so. These are the things you can do.

copy:crate
The sprite grid is replaced by one taken from another object, in this case the crate object. Note:
  • If the object does not exist, the default square is used instead.
  • the copy: transform can be written on the first line, for compatibility. This usage is deprecated.
  • flip:right
    Mirrors the grid vertically, left <-> right. As expected, down mirrors the grid horizontally, up <-> down.

    The shorthands - and | do the same, horizontal and vertical.

    shift:down:3
    Shifts the pixels of the grid down 3, in a circular fashion. Pixels falling off the bottom reappear at the top. You can use negative numbers too.
    rot:up:right
    Rotates the grid so that what was up is now right. In this case, that would be a 90 degree rotation.
    translate:right:5
    Moves the grid across 5 pixels to the right. You can use negative numbers too.

    In each case of an absolute direction you can use the relative directions > < ^ v instead. This becomes important when used in conjunction with tags.

    Text Sprites PuzzleScript Next

    Instead of a sprite matrix, you can create an object that displays as a string of text. You can see it working in 333. Use it like this.

    s; purple; text: S
    t; orange; text: tea for two
    3; pink; text: 3
    4; pink; text: 4
    number8 scale: 0.5; green; text: 8
    

    These are the things you can do.

    text: 2048
    The string of characters is trimmed and centred to fit in the cell. Text objects use the custom font, or Monospace fallback, rather than the built-in font.
    scale: 0.8
    The text is scaled, relative to 1.0.