Pickups and Score
Scatter pickups in a second colour, then teach the look-ahead PEEK a new trick: tell wall from pickup from empty by the character code it reads. Roll over a pickup, collect it, and the score climbs on a status row that never disturbs the maze.
A maze with nothing to collect is just a corridor. Scatter some pickups — bright dots in their
own colour — and give the rover a reason to explore. The clever part: the same look-ahead PEEK
that spots a wall can tell a pickup apart from a wall, just by the character it finds.
10 POKE 53281,0:PRINT CHR$(147)
20 GOSUB 500
30 SC=0:GOSUB 700
40 R=4:C=5
50 POKE 1024+R*40+C,160:POKE 55296+R*40+C,7
60 J=PEEK(56320)
70 NR=R:NC=C
80 IF (J AND 1)=0 THEN NR=R-1
90 IF (J AND 2)=0 THEN NR=R+1
100 IF (J AND 4)=0 THEN NC=C-1
110 IF (J AND 8)=0 THEN NC=C+1
120 IF NR=R AND NC=C THEN 60
130 TC=PEEK(1024+NR*40+NC)
140 IF TC=160 THEN 60
150 IF TC=81 THEN SC=SC+10:GOSUB 700
160 POKE 1024+R*40+C,32
170 R=NR:C=NC
180 POKE 1024+R*40+C,160:POKE 55296+R*40+C,7
190 GOTO 60
500 FOR C=1 TO 38
510 POKE 1024+40+C,160:POKE 55296+40+C,1
520 POKE 1024+23*40+C,160:POKE 55296+23*40+C,1
530 NEXT C
540 FOR R=1 TO 23
550 POKE 1024+R*40+1,160:POKE 55296+R*40+1,1
560 POKE 1024+R*40+38,160:POKE 55296+R*40+38,1
570 NEXT R
580 FOR R=3 TO 12:POKE 1024+R*40+19,160:POKE 55296+R*40+19,1:NEXT R
590 FOR C=8 TO 30:POKE 1024+16*40+C,160:POKE 55296+16*40+C,1:NEXT C
600 POKE 1024+4*40+12,81:POKE 55296+4*40+12,3
610 POKE 1024+10*40+30,81:POKE 55296+10*40+30,3
620 POKE 1024+14*40+10,81:POKE 55296+14*40+10,3
630 POKE 1024+20*40+15,81:POKE 55296+20*40+15,3
640 POKE 1024+20*40+33,81:POKE 55296+20*40+33,3
650 RETURN
700 POKE 1024+1,19:POKE 1024+2,3:POKE 1024+3,15:POKE 1024+4,18:POKE 1024+5,5
710 FOR I=1 TO 5:POKE 55296+I,7:NEXT I
720 S$=STR$(SC)
730 FOR I=1 TO LEN(S$)
740 POKE 1024+6+I,ASC(MID$(S$,I,1)):POKE 55296+6+I,7
750 NEXT I
760 RETURN
The pickups are POKEd in lines 600–640 — character 81, a round dot, in cyan (3) so they read
as "go here", distinct from the white walls. The new cleverness is in the collision check. Line
130 now stores what the look-ahead PEEK finds: TC = PEEK(1024 + NR*40 + NC). Then line 140
blocks the move if TC is a wall (160), but line 150 does something new — if TC is a pickup
(81), it adds 10 to the score SC and lets the rover move in. Rolling onto the pickup draws the
rover over it, so it's collected and gone.
That's three outcomes from one read: wall (160) stops you, pickup (81) scores, anything else
is open space you move into freely. The score itself is drawn by the routine at line 700, which
POKEs SCORE and the number onto the top row — written straight to screen memory so updating it
never scrolls or disturbs the maze below. Read the cell ahead, branch on what's there — the
same pattern as walls, now doing more.
Try this
- Worth more. Change the
SC = SC+10on line 150 toSC+25, or give different pickups different values by POKEing them as different characters and testing for each. - A pickup tone. Add a bright SID blip on collection (line 150) so a point is heard as well as seen — distinct from the bump tone, so your ear knows which happened.
What's next
You can collect and score, but the game never ends — there's always another pickup, or none left and nothing happens. In Unit 5 counting the pickups down gives the game a finish.