TRS-80 Pong80.BAS
Tap the screen below to play.
Controls: Tap to control your paddle, don't hold down the buttons. Left Paddle: A = up, Z = down Right Paddle: O = up, L = down
This Pong Clone was adapted from a listing in the September 1980 issue of 80 Micro, written by Ronald Moehills. It's a simple game that doesn't run very well, but a good example of what you can do in under 50 lines.
The Listing
10 REM PONG-80
20 Q=20 : A =25 : REM ** Upper and lower Y values of the left paddle
30 L=25 : O= 20 : REM ** Upper and lower Y values of the right paddle
40 CLS: LL = 0 : RR = 0 : PRINT @132, LL : PRINT @186, RR : REM ** Scores and displaying them
We start with initializing. Our paddles are defined by their Y coordinates. Scores are displayed with the PRINT@ statement to tell them where to go.
50 FOR Y = 9 TO 39 : SET (0,Y): SET (127,Y) : NEXT Y : REM ** DRAWS THE WALLS
60 C=1
70 PRINT @158,"PONG-80"
80 K=1
90 FOR I=20 TO 25: SET (7,I): SET (120,I):NEXT I
100 FOR X=1 TO 126:SET(X,9):SET (X,39): NEXT X
We draw the walls by manually turning pixels "on" with the SET
command.
110 Y=10:X=RND(100)+10
120 SET(X,Y)
We give our ball a random start and draw it with its x/y coordinates.
130 FOR I=1 TO 5:NEXT I
140 RESET (X,Y)
150 A$=INKEY$
155 IF A$="" THEN 200
160 IF A$="O" OR A$="o" THEN GOSUB 400
170 IF A$="L" OR A$="l" THEN GOSUB 410
180 IF A$="A" OR A$="a" THEN GOSUB 420
190 IF A$="Z" OR A$="z" THEN GOSUB 430
We get our input with $INKEYS
and this is why we have to tap, not hold, to play.
200 X=X+C
210 Y=Y+K
Moving our ball.
220 IF Y<39 AND Y>9 THEN 243
230 IF X>122 THEN 330
240 IF X<6 THEN 310
242 IF POINT(X,Y) THEN 270
243 IF X>122 THEN 330
244 IF X<5 THEN 310
250 IF POINT(X,Y) THEN 290
260 GOTO 120
270 K=-K
280 GOTO 210
290 C=-C
300 GOTO 200
Checking to see if we hit a wall or score a point.
310 RR=RR+1: IF RR>15 THEN 340
320 PRINT @186,RR;:GOTO 110
330 LL=LL+1: IF LL>15 THEN 340
335 PRINT @132,LL;:GOTO 110
340 PRINT@970,"": INPUT "PLAY AGAIN";B$
350 IF LEFT$(B$,1)="Y" OR LEFT$(B$,1)="y" THEN 40 ELSE END
Assigning points, checking to see if somebody wins, offering to play again.
400 RESET(120,L):O=O-1:L=L-1:SET(120,O):RETURN
410 RESET(120,O):O=O+1:L=L+1:SET(120,L):RETURN
420 RESET(7,A):Q=Q-1:A=A-1:SET(7,Q):RETURN
430 RESET(7,Q):Q=Q+1:A=A+1:SET(7,A):RETURN
Finally we have our paddle movement subroutines.