Skip to content
Game 4 Unit 2 of 8 1 hr learning time

The Cursor

Display a cursor character using position variables and the erase-update-draw pattern.

25% of Hot And Cold

In Colour Flood, the player watched the screen. In Hot and Cold, the player moves around it. To move something on screen, you need two ingredients: a character to display and variables to track where it is.

A Cursor on Screen

  26 LET r=10: LET c=15
  32 PRINT AT r,c; INK 6; BRIGHT 1;"+"

Type RUN. A bright yellow ”+” appears near the centre of the black screen. That’s the player’s cursor — their presence on the grid. It doesn’t move yet, but it’s there, glowing against the dark background.

Variables r and c store the cursor’s row and column. PRINT AT r, c draws the ”+” at that position. Change r or c and you change where the cursor appears.

Position Variables

Instead of fixed numbers in PRINT AT, the cursor uses variables:

  • r — the row (vertical position, 0 = top, higher = further down)
  • c — the column (horizontal position, 0 = left, higher = further right)

To move down, increase r. To move up, decrease r. To move right, increase c. To move left, decrease c. The grid becomes a coordinate system — two numbers define a location, and changing them moves the cursor.

The Erase-Update-Draw Pattern

Moving a character on screen takes three steps:

  1. Erase — print a space at the old position (wipe the old ”+” away)
  2. Update — change r or c (the cursor is now logically somewhere new)
  3. Draw — print the character at the new position (make the new ”+” appear)

This pattern is fundamental. Without the erase step, every movement leaves a trail of ”+” characters behind — the old ones stay on screen because the Spectrum doesn’t clear anything automatically. You have to do it yourself, explicitly, every time. There’s no sprite system, no automatic redraw. Every pixel on screen is your responsibility.

Erase-update-draw is one half of the game loop. The other half — reading input and deciding what to change — comes in the next unit. Together, they form the pattern you’ll use in every game that has moving objects.

Try This

Move it down. After displaying the cursor, add these three lines: PRINT AT r, c; " " then LET r = r + 1 then PRINT AT r, c; INK 6; BRIGHT 1; "+". The cursor jumps down one row. The old position goes blank. The new position lights up.

Different starting position. Change r and c to start the cursor in a corner instead of the centre. LET r = 1: LET c = 1 puts it top-left. LET r = 20: LET c = 30 puts it bottom-right.

Different character. Replace ”+” with ”@” or ”#” or ”*”. Pick something that stands out against a black background. The character is a design choice — games used all sorts of markers.

What You’ve Learnt

  • Position variablesr for row, c for column; two numbers define a location on screen
  • Erase-update-draw — print a space at the old position, change the variable, print at the new position; the fundamental movement pattern
  • BRIGHT 1 — makes the cursor stand out against the dark background