A short racing game from an article on faster pseudorandom numbers. Instead of RND, which is slow, the program reads bytes from the ROM starting at a random address, and uses them to decide which way the road turns. The road scrolls up the screen; steer the star with Y (left) and 8 (right) to stay between the edges. When you hit an edge, the program shows how far you got and starts again.
In 2K the game needs three extra lines (22 to 26) that fill the display file before it starts; the download has both versions. The article also prints two short listings comparing the speed of RND with reading the ROM.
Published in Syntax October 1983 (Faster Pseudorandom Numbers).
Source Code
10 REM "RACER"
20 REM USE "Y" AND "8" TO STEER
30 LET S=0
40 LET R=RND*1000
50 LET G=15
60 LET A=16
70 SCROLL
80 LET XA=A
90 LET N=PEEK (R+S)/256
100 LET G=G+(N>.5 AND G<22)-(N<.5 AND G>0)
110 LET K$=INKEY$
120 LET A=A+(K$="8")-(K$="Y")
130 PRINT AT 21,31;AT 21,G;"███ ███ ";AT 11,A;
140 IF PEEK (PEEK 16398+256*PEEK 16399)<>0 THEN GOTO 180
150 PRINT AT 10,XA;" ";AT 11,A;"*"
160 LET S=S+1
170 GOTO 70
180 PRINT S
190 PAUSE 1E4
200 CLS
210 RUN
22 FOR S=0 TO 21
24 PRINT TAB 31;" "
26 NEXT SNote: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.


