Here’s another game for your TS 1000 or ZX81. I call it “MARBLES”. It uses the same screen-reading technique as my last program (“MINES”).
This program is a pinball-like marbles game. The object of the game is to score the most points by dropping your marbles into the high-scoring slots. At the beginning, you are asked for the number of players. (Enter 0 to watch the T/S 1000 play with itself). Then type in the names of each player.
For each turn, you have five marbles. Press a key to launch a marble. The computer will play its own marbles automatically. After five turns, the game is over.
Lines 10 through 45 print out the triangle-shaped field of pins that the marbles bounce down through. Lines 50 through 130 set up the rest of the game board, input the players’ names and reset the players’ scores. The arrays P$() and S() hold the players’ names and scores. The variable N is the number of players.
The main part of the program is from line 200 to line 240, where the marbles are falling down towards the score slots and bouncing off pins along the way. This is accomplished by repeating a loop of instructions that do the following:
1) Look at the screen immediately below the marble (at line 1000). The content of the screen at that point is stored in the variable C.
2) If a pin is at that point (if C=3), move the marble randomly to the right or left of the pin. (Add or subtract 1 from variable X. The co-ordinates of the marble at any given time are stored in Y and X.
3) Now move the marble down one position. (Add 1 to Y.)
4) If we are at the bottom of the screen (if Y=20) then skip to the scoring part; otherwise repeat the loop.
Scoring is easy. Just look at the screen below the marble when it reaches the bottom (get C) and subtract 28. If you look in the back of your TS 1000 user manual (you still have it, right?), on page 138, you will find the TS 1000 character codes.
Look at the code for “3”. It’s 31. This is returned from line 1000 when the marble lands on a “3”. Subtract 28 and we get 3, our score. Now find the code for an asterisk. Subtract 28 from that to get -5 ! Your best bet is to avoid landing your marbles here!
Type in the program and play a few games. Scoring is (theoretically) completely random, but the TS 1000 seems to win more often than not! See you next issue!
5 REM MARBLES BY JIM RODLIN
10 FOR Y=0 TO 7
15 LET HS=0
16 LET W$=""
20 RAND 0
25 LET X=Y
30 FOR X=15-X TO 15+X STEP 2
35 PRINT AT Y*2+1,X;CHR$ 3
40 NEXT X
45 NEXT Y
50 PRINT AT 1,0;"[Five GRAPH
IC/SHIFT-7's]"
55 PRINT AT 20,6;"@ @ @ @ @ @ @ @ @" ["@"=GRAPHIC/SPACE]
60 PRINT TAB 6;"@9@3@1@*@5@0
@1@3@7@"
65 PRINT AT 2,0;"NUMBER OF P
LAYERS?"
70 INPUT N
75 LET N=N+1
80 PRINT AT 2,0;"[18 Spaces]
"
85 DIM P$(N,8)
90 DIM S(N)
95 FOR X=1 TO N-1
100 INPUT P$(X)
105 LET S(X)=0
110 PRINT AT X+1,0;P$(X);" ";
S(X)
115 NEXT X
120 LET P$(N)="T/S 1000"
125 LET S(N)=0
130 PRINT AT N+1,0;P$(N);" ";
0
135 FOR T=1 TO 5
140 PRINT AT N+2,0;"TURN ";T
145 FOR P=1 TO N
150 PRINT AT 0,20;P$(P)
155 PRINT AT 0,0;"OOOOO"
160 FOR B=4 TO 0 STEP -1
165 LET Y=0
170 LET SC=PEEK 16396+256*PEE
K 16397
175 IF NOT P$(P)="T/S 1000" T
HEN IF INKEY$="" THEN GOTO 175
180 FOR X=B TO 14
185 PRINT AT Y,X;"O";AT Y,X;" "
190 NEXT X
195 PRINT AT 0,15;"O";AT 0,15
;" "
200 GOSUB 1000
205 PRINT AT Y,X;" "
210 IF C=3 THEN LET X=X+1-(2
AND INT (RND*10)<5)
215 IF C=3 THEN PRINT AT Y,X;
"O"
220 LET Y=Y+1
225 PRINT AT Y-1,X;" "
230 PRINT AT Y,X;"O"
235 IF Y=20 THEN GOTO 245
240 GOTO 200
245 GOSUB 1000
250 LET S(P)=S(P)+(C-28)
255 PRINT AT P+1,9;S(P);" "
260 PRINT AT Y,X;" "
265 NEXT B
270 NEXT P
275 PRINT AT N+2,p;"[Six spac
es]"
280 NEXT T
285 PRINT AT 0,20;"[Eight spa
ces]"
290 IF N=1 THEN GOTO 355
295 FOR X=1 TO N
300 IF S(X)=HS THEN GOSUB 345
305 IF S(X)>HS THEN GOSUB 335
310 NEXT X
315 PRINT AT 0,16;"THE WINNER WAS:"
320 IF W$="T/S 1000" THEN LET
W$="*ME*"
325 PRINT AT 1,23-(LEN W$)/2;
W$
330 STOP
335 LET W$=P$(X)
336 LET HS=S(X)
340 RETURN
345 LET W$="TIE"
350 RETURN
355 PRINT AT 1,18;"HIGH SCORE
:"
360 IF S(1)>HS THEN LET HS=S(
1)
365 PRINT AT 1,29;HS
370 GOTO 120
1000 LET C=PEEK(SC+33*(Y+1)+X+
1)
1005 RETURN
2000 SAVE "MARBLE@" ["@" = GRA
PHIC/S)
2005 RUN
Transcription note: in lines 55, 185 and 315 a space inside the quotes fell at a row break of the printed listing and was lost; it is restored here (in line 185 it is the space that erases the marble).
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.