A bat-and-ball game. Keys 5 and 8 move a hollow box along the bottom row while a yellow ball bounces around the screen, beeping off each wall. Being directly under the ball as it comes down knocks it back up for two points. The ball changes to a squashed shape where it meets a wall. You have three lives. The game shows your score and the best score of the session, and ENTER starts a new game.
The REMs at the top credit Peter Shas, with the original idea by Alan Dennis. The program was saved on the disk under the name “Spider”.
Program Analysis
Structure
- Lines 40–65: set the high score, load the UDGs (9000), and set up a game (8000).
- Lines 70–190: the main loop. It moves the bat, erases and moves the ball, reverses
mornat the edges, checks for a hit, and prints the score. - Lines 500–530: lose a life, play a falling tone and restart the ball at a random spot.
- Lines 600–640: game over, with the score, the high score
hi, and a restart. - Lines 8000–8990 set the colours, positions, direction, score and lives. Lines 9000–9060 define UDGs a–d: the ball, the ball squashed flat, the ball squashed sideways, and the hollow-box bat.
Notable Techniques
- The bat moves with
LET v=v+(INKEY$="8" AND v<31)-(INKEY$="5" AND v>0), which uses Boolean arithmetic and keeps the bat on screen. - Lines 140–150 swap in a squashed ball graphic at the top, bottom and side walls.
- Line 9000 pokes all four UDGs in one loop from
USR "a"toUSR "d"+7.
Potential Issues
- A life is lost only when the ball lands on the bat’s square on row 20 (line 170,
b=v). A ball that misses the bat just bounces off the bottom row with no penalty. The test may have been meant asb<>v. - Line 500 prints the flashing red “lost” box at column 0, not at the bat’s position. It stays there until the bat passes over it.
- Line 65 prints “lives left” and line 515 prints “Lives left”.
- The yellow ball on a white background is hard to see.
This program came from an Oliger (JLO SAFE) disk, where it was saved as “Spider”, and was converted to load from tape. A garbage line after the program and the unreadable saved variables were dropped. It does not autostart, so type RUN. It was tested in ZEsarUX.
Source Code
10 REM box-bounce
20 REM Peter Shas
30 REM Original idea by Alan Dennis
40 LET hi=0
50 GO SUB 9000
60 GO SUB 8000
65 PRINT AT 21,15;"lives left ";lives
70 PRINT AT 20,v;" "
80 LET v=v+(INKEY$="8" AND v<31)-(INKEY$="5" AND v>0)
90 PRINT AT 20,v; INK 5; BRIGHT 1;"d"
100 PRINT AT a,b;" "
110 LET a=a+m: IF a>19 OR a<1 THEN BEEP .05,10: LET m=-m
120 LET b=b+n: IF b>30 OR b<1 THEN BEEP .05,15: LET n=-n
130 PRINT AT a,b; INK c;"a"
140 IF a=0 OR a=20 THEN PRINT AT a,b; INK c;"b"
150 IF b=0 OR b=31 THEN PRINT AT a,b; INK c;"c"
160 IF a=19 AND b=v THEN PRINT AT a,b; INK c;"c": BEEP .05,15: LET sc=sc+2: LET m=-m
170 IF a=20 AND b=v THEN GO SUB 500
180 PRINT AT 21,0;"Score ";sc
190 GO TO 70
500 PRINT AT 20,0; FLASH 1; INK 2;"d"
510 LET lives=lives-1
515 PRINT AT 21,15;"Lives left ";lives
520 FOR p=1 TO 20: BEEP .006,-p: NEXT p
525 IF lives=0 THEN GO TO 600
526 LET a=INT (RND*5)+2: LET b=INT (RND*27)+2
530 RETURN
600 PRINT AT 2,10; FLASH 1; BRIGHT 1;"GAME OVER"
610 PRINT '''" You scored ";sc
620 IF sc>hi THEN LET hi=sc
630 PRINT ''" Highest score today ";hi
640 INPUT "Press ENTER to play again "; LINE a$: CLS : GO TO 60
8000 BORDER 7: PAPER 7: INK 0
8005 LET v=15: LET a=INT (RND*5)+2: LET b=INT (RND*27)+2
8010 LET sc=0: LET m=1: LET n=1
8020 LET c=6: LET lives=3
8990 RETURN
9000 FOR a=USR "a" TO USR "d"+7
9010 READ user: POKE a,user
9020 NEXT a: RETURN
9030 DATA 60,126,255,255,255,255,126,60
9040 DATA 0,0,0,60,126,255,126,60
9050 DATA 8,28,62,62,62,62,26,6
9060 DATA 255,129,129,129,129,129,129,255Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.
