← PathwayLesson 3 · Tilesets & TilemapsNext lesson →
CREATE

Pixel Courier tileset6 tiles · 16 × 16 each

Lesson 03 · 65 minutes · World layer

Build a world from 16-pixel bricks.

A tileset is a small set of square pieces. A tilemap is a grid that says which piece goes where. With six tiles and a text grid you can build every level in Pixel Courier.

TILESETTILEMAPSEAMLESS EDGESCOLLISION LAYERAUTOTILINGBITMASK
01 / WHY

Where this comes from

Tiles let a tiny memory hold a huge world.

1980

Pac-Man’s maze is built on a grid of tiles, and console games of the 1980s stored levels as lists of tile numbers instead of full pictures. A screen of 8 × 8 tiles needs one byte per tile — far less than one byte per pixel.

The Maze tutorial already uses this idea: its walls are a grid. Here you draw the tiles yourself and see the grid as text.

02 / TILES

Tileset lab

Paint tiles that tile.

  1. Pick a tile.G grass, D dirt, B brick, C crate, = one-way plank, ^ spikes.
  2. Paint, then run the seam test.Use dirt for an all-direction seam test: look for unwanted lines in the 4 × 3 preview. Grass has an intentional top edge; test it in a horizontal row.
  3. Keep the rules.Changing the picture never changes whether a tile is solid — that lives in the tile’s data.
03 / MAP

Tilemap lab

A level is just text.

Paint with the brushes. Watch the text version change: every character is a tile ID. 🌱 Ground (auto) is a rule tile: it places grass when nothing is above and dirt underneath. Turn on Collision layer to see what the physics will treat as solid.

Level editorShared with lessons 05–10

the same level in code
const level = [
  "..S......P...M.",
  "GGGGGGGGGGGGGGG",
  "DDDDDDDDDDDDDDD",
];
const tile = (col, row) => level[row][col];       // look up any cell
const isSolid = id => tiles[id] && tiles[id].solid; // rules live in data
Why keep “solid / one-way / hazard” in the tile’s data instead of checking its colours?

04 / AUTOTILE

Theory: autotiling

Let neighbours choose the edge.

Hand-placing “top-left corner”, “top edge”, “right wall”… is slow. Autotiling looks at the four neighbours and adds up a bitmask: up = 1, right = 2, down = 4, left = 8. The total (0–15) picks one of 16 tile variants. Click cells below.

4-Bit Autotile Bitmask Diagram showing cardinal neighbor summation formula and the 16-state tile atlas
4-Bit Autotile Bitmask: Each cardinal neighbour represents a power of two: Up (+1), Right (+2), Down (+4), Left (+8). Summing adjacent solid tiles yields a unique bitmask from 0 (isolated) to 15 (fully enclosed), indexing directly into a 16-tile atlas.

4-bit autotileClick to add or remove ground

bitmask · JavaScript
function mask(x, y) {
  return (filled(x, y - 1) ? 1 : 0)  // up
       + (filled(x + 1, y) ? 2 : 0)  // right
       + (filled(x, y + 1) ? 4 : 0)  // down
       + (filled(x - 1, y) ? 8 : 0); // left
}
const variant = groundTiles[mask(x, y)]; // 16 hand-drawn variants
05 / SHIP

Definition of done

Your world kit is ready when…

0/4 checked

Evidence: Explain to a partner how the text grid becomes both the picture and the walls.

Lesson 03 complete?

Your art and settings are already saved for the next lesson.