Drag Racer


This is a simulation of a drag race. The object of the game is to complete the quarter mile course in the shortest possible time. You have four gears and must determine the optimum moment for changing up. If you change too early, your revs will fall too low and you will lose valuable time; if you spend too much time in high revs you'll probably blow your engine. The rear end ratio of the car is progressively increased with each succeeding game, and the right moment to change gear becomes increasingly hard to judge.

    1 REM *** BBC VERSION ***
    2 REM *** DRAG RACER  ***
   10 GOSUB550
   20 DIMG(5)
   30 ENVELOPE1,2,1,-1,0,1,1,0,128,0,0,0,128,
128
   40 GOSUB670
   50 GOSUB850
   60 G=1:*FX11
   70 I=INKEY(100)
   80 IFI=109 A=A+1
   90 IFI>48 AND I<54 G=I-48
  100 IFT<3 RPM=FNAA:GOTO120
  110 RPM=FNAB
  120 IFRND(1000)>RPM-6200 GOTO140
  130 GOTO530
  140 OS=NS
  150 OP=NP
  160 TQ=FNAC
  170 TQ1=17
  180 NS=FNAD
  190 NP=FNAE
  200 T=T+1
  210 A=FNAF/2:IFA>2*PI A=2*PI
  220 X=180*SIN(A)
  230 Y=180*COS(A)
  240 IFT>1 MOVE751,335:PLOT1,XX,YY
  250 MOVE751,335:PLOT1,X,Y
  260 XX=X:YY=Y
  270 A=FNAG:IFA>2*PI A=2*PI
  280 ENVELOPE1,5-(A*2/PI),1,-1,0,1,1,0,120,0
,0,0,A*64/PI,0
  290 SOUND&10,1,5,30
  300 N=190*SIN(A)
  310 O=190*COS(A)
  320 IFT>1 MOVE340,335:PLOT1,NN,OO
  330 MOVE340,335:PLOT1,N,O
  340 NN=N:OO=O
  350 IFLIN1<8 COLOUR1:PRINTTAB(COL1,LIN1)"_"
  360 COL1=COL1+INT((NP-OP)/CL)/4
  370 IFCOL1>31 AND LIN1<8 COL1=COL1-31:LIN1=
LIN1+1
  380 IFLIN1<8 COLOUR2:PRINTTAB(COL1,LIN1)CHR
$255
  390 IFNP<5280 GOTO70
  400 T=FNAH:COLOUR3:T=INT(T*100)/100:*FX15
  410 IFT<BT BT=T
  420 NS=INT(NS*100)/100
  430 PRINTTAB(0,0)"Time ";T;" seconds."
  440 PRINT"Best time ";BT;" seconds."
  450 PRINT"Maximum speed ";NS;" mph."
  460 FORX=0TO2000:NEXT
  470 PRINT'"Press SPACE to restart."
  480 REPEATUNTILGET=32
  490 GR=GR+.1:IFGR>4.1 GR=4.11
  500 GOSUB670
  510 GOSUB990
  520 GOTO60
  530 *FX15
  540 COLOUR3:PRINTTAB(0,0)"Engine Blown.":GO
TO460
  550 MODE7:PRINT'CHR$141;CHR$&86;CHR$157;CHR
$&84"           Drag Racer             "CHR$1
56'CHR$141;CHR$&86;CHR$157;CHR$&84"          
 Drag Racer             "CHR$156
  560 PRINT'CHR$&85"In this drag racing simul
ation,you must"CHR$&85"try to cover the quart
er mile in the"'CHR$&85"shortest possible tim
e.The only"'CHR$&85"controls you need are the
 gears which"'CHR$&85"must be changed at the 
optimum moment."
  570 PRINT'CHR$&83"At the start,you are in f
irst gear and"'CHR$&83"you must watch the rpm
 counter and"'CHR$&83"decide when to change i
nto second."''CHR$&82"At over 6000 rpm there 
is a high"'CHR$&82"probability of the engine 
blowing."
  580 PRINT'CHR$&86"With each succeeding atte
mpt,the rear"'CHR$&86"and ratio is increased 
slightly which"'CHR$&86"makes the game progre
ssively more"'CHR$&86"difficult."
  590 PRINT'CHR$&81"Try not to change gear at
 the wrong"'CHR$&81"time.The gear keys are '1
' TO '5'."
  600 FORX=0TO5000:NEXT
  610 PRINTTAB(0,24)CHR$136"        Press SPA
CE to tart.";:REPEATUNTILGET=32
  620 FORX=0TO7
  630   PRINTTAB(0,X)SPC(32)
  640 NEXT
  650 FORY=640TO864STEP32:MOVE128,Y:DRAW1151,
Y
  660 NEXT:RETURN
  670 MODE1:VDU28,4,27,35,4
  680 G(1)=4
  690 G(2)=2
  700 G(3)=1.25
  710 G(4)=.8
  720 G(5)=.6
  730 T=0:NP=0:NS=0
  740 MPH=0:RPM=0
  750 FORX=-136TO136STEP4
  760   Y=SQR(36864-X*X):PLOT69,X+751,Y+335:P
LOT69,X+751,335-Y:PLOT69,Y+751,335+X:PLOT69,7
51-Y,335+X
  770   PLOT69,X+340,Y+335:PLOT69,X+340,335-Y
:PLOT69,Y+340,X+335:PLOT69,340-Y,335+X
  780 NEXT:GCOL0,1
  790 FORY=-188TO188STEP4:PLOT77,719,Y+335:PL
OT77,308,Y+335:NEXT
  800 COLOUR0:COLOUR129
  810 PRINTTAB(6,12)"0"TAB(1,17)"52  RPM  17"
TAB(6,22)"35"
  820 PRINTTAB(19,12)"0"TAB(14,17)"270 MPH  9
0"TAB(18,22)"180"
  830 COLOUR128:COLOUR2:PRINTTAB(26,20)"DRAG"
TAB(26,21)"RACER"
  850 DEFFNAA=4200*(G(G)/G(1))
  860 DEFFNAB=NS*GR*G(G)*CON/CIRC
  870 DEFFNAC=(C1*RPM^3)+(C2*RPM^2)+(C3*RPM)
  880 DEFFNAD=OS+(TQ/TQ1)
  890 DEFFNAE=OP+NS*(5280/3600)
  900 DEFFNAF=(NS*2)/180*PI
  910 DEFFNAG=(RPM/19.5)/180*PI
  920 DEFFNAH=T+(1320-OP)/(NP-OP)-1
  930 CON=63360
  940 CIRC=4523.893421
  950 C1=-1.8953E-9
  960 C2=1.02157E-5
  970 C3=.015752
  980 BT=1E9:GR=3:CL=5.176
  990 LIN1=0:COL1=0
 1000 VDU23,255,0,0,0,0,224,255,227,225,18,3,
2
 1010 RETURN