BASIC Sighting Angle Rocket Guidance Program

10 REM SIGHTANG rocket intercept display, constant sightline angle, integ
navig
20 REM List speed lookup table from dynamics program here, 160
22 REM values that represent 1/160 of expected flight in units of
24 REM target speed times 1.24375, and remove line 360 RESTORE.
26 DATA 2
38 KEY OFF
40 SCREEN 2: REM set screen hi-res
50 INPUT "Offset (+319 to -319, + is to right)? ",O
60 INPUT "Sightline Angle? ",E
80 CLS: REM clear screen
90 PRINT:PRINT:PRINT:PRINT:PRINT:PRINT:PRINT:PRINT:PRINT:REM print data out of
path of engagement
100 PRINT "Offset=(+319 to -319, + is to right)? ";O
110 PRINT "Sight Angle=(degrees, up = 0, + is to right)? ";E
120 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
140 DRAW "BM0,0": DRAW "R3": REM draw target at upper left of field
150 REM loop to draw target positions
160 DRAW "BR61":DRAW "R3":C=C+1:IF C<10 THEN 150
170 C=0 :REM zero counter
180 DRAW "BM319,199" :REM move to bottom of screen, center
190 DRAW "BR=O;":REM offset launch point
200 REM initialize variables
210 X2=639:REM set up initial target sightline
220 X4=329+O: REM set initial launch point
230 Y2=199:REM set initial height
240 REM main program loop
250 T=ATN((X2-X4)/Y2):REM find initial angle
255 T=(T*57.3)
260 READ S
270 T=-(T-E):REM rotate rocket
280 DRAW "TA=T;U=S;":REM turn angle L, move rocket
284 X4=POINT(0):REM locate rocket horiz position
286 Y2=POINT(1):REM locate rocket vertical position
288 IF X4<=0 THEN 380
290 IF Y2=0 THEN 380:REM stop if rocket above target
300 IF Y2<0 THEN 380
310 IF Y2>199 THEN 380:REM stop if rocket hit ground
320 X2=X2-4 :REM move target 4 steps
330 IF X2<0 THEN 380: REM end if target safely off screen
340 C=C+1: REM bump loop counter
350 IF C=16 THEN C=0 :DRAW "NM=X2;,0;":REM print sightlines
360 RESTORE
370 GOTO 240
380 END