Skip to content
Game 2

Colour the court

Use PAPER to make solid shapes and restore the right background when they move.

The rules are working, but the court still looks like a diagram. We can give it strong shapes using the background colour of ordinary character cells. No new character designs are needed.

Continue from Keep score and play again. Stop the game and enter these changes:

Replace lines 10, 15, 40, 50, 500, 620, 700, 900. Add line 35.

10 BORDER 0: PAPER 0: INK 7: BRIGHT 1: CLS
15 PRINT AT 3,3;"VOLLEY";AT 5,3;"A up   Z down";AT 7,3;"Q quits. Keep the rally going.";AT 9,3;"S to serve": GO SUB 800: CLS
35 PAPER 1: FOR r=3 TO 19: PRINT AT r,2;"                            ": NEXT r
40 FOR c=2 TO 30: PRINT PAPER 5;AT 2,c;" ";AT 20,c;" ": NEXT c
50 FOR r=3 TO 19: PRINT PAPER 5;AT r,30;" ": NEXT r
500 FOR r=p TO p+2: PRINT PAPER 6;AT r,2;" ": NEXT r
620 LET dx=1: LET nx=4: LET score=score+1: PRINT PAPER 0;AT 0,19;score
700 PRINT PAPER 0;AT 21,1;"Miss. R retry, Q quit."
900 PRINT PAPER 0;AT 21,1;"Finished.                    ": STOP

A space can be a coloured block

PAPER chooses a character cell’s background; INK chooses its character colour. A space has no visible character strokes, so its whole cell shows the PAPER colour. It is a useful drawing material, not an absence of drawing.

We use colour 1 for blue, 5 for cyan, 6 for yellow and 0 for black. INK 7 supplies white for the ball and text. BRIGHT 1 selects bright colours; it does not turn on FLASH. The ball’s earlier blinking comes from our drawing order, not the Spectrum’s FLASH attribute.

Line 35 sets the continuing PAPER colour to blue and fills rows 3–19 from column 2. The quoted string contains 28 spaces, covering columns 2 through 29. Those spaces matter: an empty string would fill nothing. The top, bottom and right wall loops now print spaces with cyan backgrounds instead of dashes and I characters. The paddle routine prints yellow spaces.

Keep a colour local to its drawing

PAPER 1 as a statement sets the colour used by later printing. By contrast, PRINT PAPER 6;AT r,2;" " uses yellow for that PRINT statement. It does not change the continuing blue setting. The next ordinary PRINT again uses blue.

That distinction solves a moving-object problem. When the paddle moves, its trailing cell must become blue, not yellow. When the ball is erased, its old cell must also return to blue. The space has to carry the right background.

The score and messages belong on black. Their PRINT statements explicitly use PAPER 0 so updating the score does not paint a blue patch into the dark strip.

Why not set PAPER 6 once before drawing the paddle and leave it there?

Show the explanation

Then later ordinary printing would use yellow too. Clearing the old paddle or ball with a space would leave yellow cells behind. A temporary PRINT colour lets one object look different without changing the background used for restoration.

Inspect the whole playfield

Run and serve. The ball should be white on a blue court, the walls cyan and the paddle a solid yellow shape. Move the paddle from top to bottom: the cells it leaves should become blue. Let the ball travel and inspect its old positions for patches. Score changes should retain their black background.

The shapes and positions still identify the court, paddle and ball; colour adds separation without becoming the only indication of their roles. We have kept the game silent so the ball and paddle remain the information needed to play.

Complete coloured game
10 BORDER 0: PAPER 0: INK 7: BRIGHT 1: CLS
15 PRINT AT 3,3;"VOLLEY";AT 5,3;"A up   Z down";AT 7,3;"Q quits. Keep the rally going.";AT 9,3;"S to serve": GO SUB 800: CLS
20 LET x=15: LET y=10: LET dx=1: LET dy=1
25 LET p=9: LET score=0
26 LET missed=0
30 PRINT AT 0,1;"VOLLEY   Returns: ";score
35 PAPER 1: FOR r=3 TO 19: PRINT AT r,2;"                            ": NEXT r
40 FOR c=2 TO 30: PRINT PAPER 5;AT 2,c;" ";AT 20,c;" ": NEXT c
50 FOR r=3 TO 19: PRINT PAPER 5;AT r,30;" ": NEXT r
90 GO SUB 500
100 PRINT AT y,x;"o"
105 LET k$=INKEY$
106 IF k$="q" THEN GO TO 900
110 PAUSE 2
120 PRINT AT y,x;" "
125 IF k$="a" THEN IF p>3 THEN PRINT AT p+2,2;" ": LET p=p-1
126 IF k$="z" THEN IF p<17 THEN PRINT AT p,2;" ": LET p=p+1
130 GO SUB 500
200 LET nx=x+dx: LET ny=y+dy
210 IF ny=2 THEN LET dy=1: LET ny=4
220 IF ny=20 THEN LET dy=-1: LET ny=18
230 IF nx=30 THEN LET dx=-1: LET nx=28
240 IF nx=2 THEN GO SUB 600
245 IF missed=1 THEN GO TO 700
250 LET x=nx: LET y=ny
300 GO TO 100
500 FOR r=p TO p+2: PRINT PAPER 6;AT r,2;" ": NEXT r
510 RETURN
600 IF ny<p THEN LET missed=1: RETURN
610 IF ny>p+2 THEN LET missed=1: RETURN
620 LET dx=1: LET nx=4: LET score=score+1: PRINT PAPER 0;AT 0,19;score
630 RETURN
700 PRINT PAPER 0;AT 21,1;"Miss. R retry, Q quit."
710 IF INKEY$<>"" THEN GO TO 710
720 LET k$=INKEY$: IF k$="q" THEN GO TO 900
730 IF k$<>"r" THEN GO TO 720
740 IF INKEY$<>"" THEN GO TO 740
750 GO TO 10
800 IF INKEY$<>"" THEN GO TO 800
810 LET k$=INKEY$: IF k$="q" THEN GO TO 900
820 IF k$<>"s" THEN GO TO 810
830 IF INKEY$<>"" THEN GO TO 830
840 RETURN
900 PRINT PAPER 0;AT 21,1;"Finished.                    ": STOP

We have deliberately kept the old erase-first movement loop in this checkpoint. The bold background makes its missing ball easy to notice. Keep this version for comparison: the next change will alter when we draw, rather than what colours we choose.

Sources

Steven Vickers, edited by Robin Bradbeer, ZX Spectrum BASIC Programming, second edition (Sinclair Research, 1983), chapter 16 (INK, PAPER, BRIGHT and colour controls within PRINT).