BASIC Proportional Navigation Program

20 REM PROPONAV rocket intercept display, input launch angle
30 SCREEN 2: REM set screen hi-res
40 INPUT "Offset (+319 to -319, + is to right) ";O
50 INPUT "Launch angle (degrees, up = 0, + is to right) ";L
60 INPUT "Navigational Ratio (2 to 5) ";N
70 INPUT "Rocket Speed Multiplier (1 = target speed) ";S
80 CLS: REM clear screen
path of engagement
82 PRINT "Offset=";O
84 PRINT "Angle =";L
86 PRINT "N.R.  =";N
88 PRINT "Speed =";S
90 L=-L
100 S=S*4.84: REM set rocket/target speeds to screen aspect ratio
110 DRAW "BM639,199": DRAW "M+1,0": REM draw framing dot lower right
130 DRAW "BM0,199":DRAW "M+1,0":REM draw framing dot lower left
135 DRAW "BM0,0": DRAW "R3": REM draw target at upper left of field
140 REM loop to draw target positions
145 DRAW "BR61":DRAW "R3":C=C+1:IF C<10 THEN 140
150 C=0 :REM zero counter
155 DRAW "BM319,199" :REM move to bottom of screen, center
160 DRAW "BR=O;":REM offset launch point
165 REM initialize variables
170 X2=639:X1=631 :REM set up initial sightline shift (8 steps)
185 Y1=199:Y2=199:REM set initial height
187 DRAW "A1": REM vertical reference
190 REM main program loop
191 X4=POINT(0):REM locate rocket horizontal position before move
192 Y2=POINT(1):REM locate rocket vertical position before move
200 DRAW "TA=L;U=S;":REM turn angle L, move rocket
201 X3=POINT(0):REM locate rocket horiz pos after move
202 Y1=POINT(1):REM locate rocket vert pos after move
210 IF Y1=0 THEN 350:REM stop if rocket above target
211 IF Y1<0 THEN 350
212 IF Y1>199 THEN 350:REM stop if rocket hit ground
220 T2=ATN((X2-X4)/Y2):REM calculate sightline before move
225 T1=ATN((X1-X3)/Y1):REM calculate sightline after move
230 T=(T2-T1)*57.3:REM determine sightline rotation in degrees
260 IF X1=-9 THEN 350: REM end if target safely off screen
290 L=L+(T*N):REM rotate rocket
295 IF T>9 THEN PRINT:PRINT"Round-Off Stop":PRINT:GOTO 350:REM avoid roundoff
300 X2=X2-8:X1=X1-8 :REM move target 8 steps
309 C=C+1: REM bump loop counter
310 IF C=8 THEN C=0 :DRAW "NM=X2;,0;":REM draw sightline
340 GOTO 190
350 END