Letters on Tiles
Extract individual characters with string slicing and animate them onto the tiles one by one.
The tiles are empty. This unit fills them — one letter at a time, with a rising tone on each. This animated reveal is the game’s signature visual moment, and it’s built from one new idea: string slicing.
Reaching Inside a String
10 LET w$="planet"
20 PRINT "Word: ";w$
30 PRINT "First letter: ";w$(1 TO 1)
40 PRINT "Third letter: ";w$(3 TO 3)
50 PRINT "Letters 2 to 4: ";w$(2 TO 4)
60 FOR i=1 TO LEN w$
70 PRINT w$(i TO i);" ";
80 NEXT i
w$(1 TO 1) extracts the first character. w$(3 TO 3) extracts the third. w$(2 TO 4) pulls three characters from the middle. The numbers are positions, starting at 1, and TO marks the range.
For a single character at position i, use w$(i TO i). Put that inside a FOR loop and you can walk through every letter in the word.
The Animated Reveal
5 BORDER 0: PAPER 0: INK 7: CLS
10 FOR i=0 TO 31
12 PRINT AT 0,i; PAPER 2;" "
14 NEXT i
16 PRINT AT 0,8; PAPER 2; INK 7; BRIGHT 1;" WORD SCRAMBLE "
20 PRINT AT 4,10; INK 5;"Unscramble:"
30 LET w$="planet"
32 LET c=(32-LEN w$*2)/2
34 FOR i=1 TO LEN w$
36 PRINT AT 8,c+i*2-2; PAPER 1;" "
38 PRINT AT 9,c+i*2-2; PAPER 1;" "
40 NEXT i
50 FOR i=1 TO LEN w$
52 PRINT AT 8,c+i*2-2; PAPER 1; INK 6; BRIGHT 1;w$(i TO i)
54 BEEP 0.05,5+i*2
56 NEXT i

Each letter appears on its blue tile with a rising BEEP. The loop on lines 50-56 does the work:
w$(i TO i)extracts the character at positioniPRINT AT 8, c + i * 2 - 2places it on the correct tilePAPER 1; INK 6; BRIGHT 1prints bright yellow on blueBEEP 0.05, 5 + i * 2plays a note that rises with each letter
The pitch formula 5 + i * 2 means the first letter plays at pitch 7, the second at 9, the third at 11 — a climbing scale that builds anticipation. When the last letter lands, the word is complete.
Why TO and Not Just a Number?
On many computers, w$(3) gives you the third character. On the Spectrum, w$(3) is shorthand for w$(3 TO 3) — it works, but the TO syntax is more flexible. w$(2 TO 5) gives you four characters in one go. You’ll use longer ranges in the next unit.
Try This
Slower reveal. Change BEEP 0.05 to BEEP 0.15 for a more dramatic, slower appearance. Each letter hangs in the air before the next arrives.
Descending pitch. Replace 5 + i * 2 with 20 - i * 2. The notes fall instead of rising — a different mood entirely.
What You’ve Learnt
- String slicing —
w$(i TO i)extracts a single character at positioni - Ranges —
w$(2 TO 4)extracts characters 2 through 4 - Animated reveal — a FOR loop placing one character at a time with BEEP
- Rising pitch —
5 + i * 2creates an ascending tone sequence