Classic Computer Magazine Archive COMPUTE! ISSUE 73 / JUNE 1986 / PAGE 56



UFO Invasion
For IBM And Amiga

John Robinson

This arcade game sets up a classic confrontationyou, the lone defender, against a horde of deadly machines from outer space. The original IBM version requires Cartridge BASIC for the PCjr or BASICA and a color/graphics adapter for the PC. We've also translated the game for the Amiga computer.

You are at the controls of a surface-to-air missile launcher located somewhere near the Arctic Circle. Your radar outposts have detected a fleet of unidentified flying objects (UFOs) invading the North American continent. Forewarned about this possibility, you know that the waves of UFOs will attack your missile site before proceeding to the more populous areas lying southward. Are you up to the challenge?
    Though it's not a particularly long program, "UFO Invasion" offers quite a test for your gaming skills, particularly at the higher levels. Type in the version for your computer and save a copy before you run it. As the screen photos illustrate, both versions look and play almost identically.
    Since the Amiga version doesn't use line numbers, we've used a special character (a left arrow) to show you where each program line ends. Don't try to type in the arrows-they're present only to show you where each line ends. (Actually, you can't type an arrow even if you want to, since we deliberately picked a symbol that's not available on the Amiga keyboard.) Instead, wherever you see a left arrow in the listing, you should press RETURN or move the cursor off the line to enter it into memory. To illustrate, look at these program lines:

DEFINT A-Z←
RANDOMIZE TIMER
SCREEN 1, 320, 200, 2, 1
WINDOW 1,"UFO Invasion",(0,0)-(3
11,185),20,1


    The first three lines are short enough to fit into one magazine column, but the fourth program line is so long that it wraps around onto a second line. The arrow shows you that the line ends after the final 1, not after the 3.

First Line Of Defense
When UFO Invasion begins, you'll hear the sound of an alarm siren and see two warning messages scroll across the screen. The middle of the screen contains your control panel. The observatory window at the top gives you a direct view of the skyline in your defense sector. Within the window is the aiming crosshair for your missile launcher, and directly below is a radar screen.
    When the saucer-shaped UFO appears, your job is to move the crosshair onto the UFO (using the cursor keys) and launch a missile at it (by pressing the space bar). If your missile hits the UFO, the automated craft is vaporized immediately.
    Before it can fire at your base, the UFO must locate your position. Once your position is located, the UFO is certain to hit the mark. Your force shields are powerful enough to protect you against three hits by the UFO, but the fourth hit neutralizes your defenses and paves the way for a successful invasion (ending the game as well).

Control Panel
The control panel is equipped with six gauges to help you monitor events. On each side of the circular radar screen are two ladder gauges. The gauge at the far right shows you how many UFOs remain to be eliminated in the current level. There are eight levels in all; you must eliminate 29 UFOs at each level before advancing to the next.
    The gauge directly to the right of the radar screen indicates how close the UFO is to locating your position. When this indicator reaches the top, the UFO scores a hit. The gauge at the far left shows your points for the current level. You receive 100 points (shown as one bar on the ladder) for each UFO you destroy, with an additional bar for hitting the UFO before the timer is halfway to the top. If you score two bars for every UFO on the current level, you receive a bonus equal to 1,000 points times the level number.
    Directly underneath the radar screen are two additional indicators that show you how many levels have been completed, and how many hits your shields have sustained.
    Press the cursor keys to move the aiming crosshair left, right, up, or down. To fire a missile, press the space bar. You can quit the game at any time by pressing Q. In levels 1, 2, 4, 6, and 8 you can view the UFOs through the observatory window. In levels 3, 5, and 7 the sky is obscured by a thick cloud cover, forcing you to guide the missiles by radar alone. The radar screen shows the position of the UFO in relation to your aiming crosshair. Aim with the cursor keys until the red dot is in the center of the radar panel, then fire.

Amiga Version
Converting the original PC/PCjr game to Amiga BASIC was a very easy project. First, we used modems to transfer the PC program text to the Amiga over the phone line. Then we changed a few lines that were obviously unusable in Amiga BASIC (those with KEY and PLAY statements). In less than an hour, after changing about a dozen program lines, we had the PC game running on the Amiga-a testament to the close similarity between the BASICS on both machines.
    Though the two programs look very different on the surface, the differences are largely cosmetic. To improve the Amiga program's readability and make it easier to type, we stripped off the line numbers, substituted meaningful labels where needed, and chopped most multi-statement lines into singlestatement lines. Line numbers are unnecessary in Amiga BASIC; statements like GOSUB PrintMessage and GOTO MainLoop are much easier to understand than numberoriented statements like GOSUB 890. And in most cases there's little to gain by "crunching" multiple statements onto one line. We made no efforts to speed up the Amiga version, yet because of the Amiga's speedier processor, this program runs much faster than the PC/PCjr game.
    If you compare the two programs statement by statement, you'll see that they're still nearly identical. Of course, the Amiga needs SCREEN and WINDOW statements to create a graphics screen equivalent to the original PC/PCjr screen. Since ON KEY and PLAY don't exist in Amiga BASIC, substitutes had to be found there as well (we used INKEY$ to read the keyboard and SOUND for sound effects). But the meat of the program-high-resolution drawing with LINE statements and animation with GET and PUT-is exactly the same.
    If you're a PC owner who just bought an Amiga, or an Amiga owner looking for more type-in programs, this project shows how simple it can be to convert programs from IBM BASIC to Amiga BASIC. (Another language which is even more similar to Amiga BASIC is Microsoft BASIC for the Macintosh.) As a general rule, any game that relies chiefly on LINE, GET, and PUT should transfer from the PC to the Amiga quite easily. Just be sure to set up the right sort of screen at the beginning of the program.
    To highlight the similarity between the two versions of BASIC, we did not add many machine specific features to the Amiga version. However, you may find it interesting to add some extra features of your own. For instance, why not add voice synthesis to the messages that scroll across the screen? If you have a stereo hookup, you might want to modify the sound routines to take advantage of the Amiga's stereo sound capabilities. The Amiga version of "Switchbox" (COMPUTE!, March 1986) contains examples of how to do both, as well as other tips on writing games in Amiga BASIC. On a larger scale, you might want to try enlarging the playfield. In the original PC/PCjr version, the game screen is kept quite small to make the game run faster. But Amiga BASIC is fast enough to permit convincing animation within a much larger area.

Program 1: UFO Invasion For
IBM PC/PCjr

For instructions on entering this listing, please
refer to "COMPUTE!'s Guide to Typing In
Programs" in this issue of COMPUTE!.


LA 10 REM ---------- INITIALIZE
      VARIABLES ----------
PN 20 SCREEN 1:COLOR 0,0,0:CLS:K
      EY OFF:RANDOMIZE TIMER:PLA
      Y "mb"
BF 30 DIM SH(2000),UFO(200),GD(2
      00),X(30),Y(30),RADAR(50)
IG 40 L=1:TL=B:LIVES=O:SCORE=0:R
      X=100/15:RY-50/12
EL 50 REM ---------- SET UP SCRE
      EN -----------
IJ 60 LINE (111,51)-(211,159),3,
      B:LINE (111,101)-(211,101)
      ,3
NC 70 LINE (121,101)-(121,159),3
      :LINE (131,101)-(131,159),
      3
AF 80 LINE (191,101)-(191,159),3
      :LINE (201,101)-(201,159),
      3
JP 90 FOR Y=157 TO 103 STEP -2
FF 100 LINE (111,Y)-(131,Y),3:LI
       NE (191,Y)-(211,Y),3
NJ 110 NEXT Y
HL 120 CIRCLE (161,120),16,1:CIR
       CLE (161,120),10,1:CIRCLE
        (161,120),4,1
MO 130 LINE (146,120)-(176,120),
       1:LINE (161,108)-(161,132
       ),l
IB 140 FOR X=145 TO 173 STEP 4:L
       INE (X,135)-(X+4,140),3,B
       :NEXT X
DA 150 FOR X=154 TO 162 STEP 4:L
       INE (X,147)-(X+4,151),3,8
       :NEXT X
EJ 160 LINE (1,0)-(6,0),1:LINE
       0,1)-(7,1),1:LINE
       7,2),3
IJ 170 LINE (0,3)-(7,3),1:LINE
       1,4)-(6,4),1:GET (0,0)-(7
       ,6),UFO
JM 180 LINE (0,0)-(7,7),O,BF
LE 190 LINE (0,3)-(4,3),2:LINE
       2,1)-(2,5),2:OET (0,0)-(5
       ,5),GD
IN 200 LINE (0,0)-(7,7),0,BF
EM 210 GOSUB 270:B$=" ENEMY ALER
       T":GOSUB 250
GE 220 B$=" UFO INVASION":GOSUB
       250
LA 230 LINE (0,0)-(1,1),2,BF:8ET
       (0,0)-(1,1),RADAR

IBM/PCjr Version
The IBM PC/PCjr version of "UFO In-
vasion" pits you, the lonely defender in
an Arctic wasteland, against waves of
oncoming robot craft.


DP 240 GOTO 320
PA 250 FOR I=1 TO 39:LOCATE 1,1:
       FOR SA=1 TO 20:NEXT SA:PR
       INT LEFTf(B$,40-I):NEXT I
MI 260 RETURN
HK 270 FOR I=1 TO 10
KC 280 FOR P=1000 TO 1900 STEP 2
       5:SOUND P,.2:NEXT P
OK 290 NEXT I
MN 300 RETURN
JA 310 REM ---------- SET UP KEY
       BOARD -----------
KD 320 DEF SEG=0:POKE 1047,PEEK(
       1047) OR 64
DC 330 ON KEY (11) GOSUB 630:KEY
       (11) ON
IL 340 ON KEY (12) GOSUB 640:KEY
        (12) ON
ME 350 ON KEY (13) GOSUB 650:KEY
        (13) ON
BN 360 ON KEY (14) GOSUB 660:KEY
        (14) ON
JN 370 KEY 15,CHR$(&H40)+CHR$(&H
       39):ON KEY (15) GOSUB 670
       :KEY (15) ON
OE 380 KEY 16,CHR$(&H40)+CHR$(&H
       10):ON KEY (16) 80SUB 680
       :KEY (16) ON
CB 390 REM ---------- START A NE
       W LEVEL ----------
CC 400 B=160:PTS=0:T=0
IG 410 FOR S=158 TO 102 STEP -2:
       LINE (202,S)-(210,S),2:NE
       XT S
IC 420 IF L=3 OR L=5 OR L=7 THEN
       CLR=0:GOTO 440 ELSE CLR=
       1
MA 430 FOR S=1 TO 60:PSET(112+RN
       D*98,52+RND*48),INT(RND*4
       ):NEXT S
EA 440 S=100
FF 450 XU=112+RND*90:YU=52+RND*4
       0:IF CLR THEN PUT(XU,YU),
       UFO,XOR
FF 460 XG=160:YG=75:PUT(XG,YG),G
       D,XOR
QJ 470 LINE(142+L*4,136)-(144+L*
       4,139),1,BF
OC 480 REM ---------- PERFORM MA
       IN LOOP -----------
CD 490 GOSUS 700 ' MOVE CROSS HA
       IRS
LO 500 GOSUB 550 ' MOVE UFO
BD 510 IF FIRED THEN GOSUB 770:I
       F S=158 THEN 1000
ON 520 T=T+1:IF T>TL THEN B=B-2:
       T=0:LINE(192,B)-(200,8),2
       :IF B=102 THEN GOSUB 1190
        ' CHECK TIME
IH 530 GOTO 490
KK 540 REM ---------- MOVE UFO &
        RADAR ----------
KF 550 IF RND<.1 THEN CXU=RND*10
       -5:CYU=RND*6-3
PD 560 IF CLR THEN PUT (XU,YU),U
       FO,XOR
LM 570 XU=XU+CXU:IF XU>200 THEN
       XU=200 ELSE IF XU<112 THE
       N XU=112
GN 580 YU=YU+CYU:IF YU>90 THEN Y
       U=90 ELSE IF YU<52 THEN Y
       U=52
QJ 590 IF CLR THEN PUT (XU,YU),U
       FO,XOR
LF 600 PUT(XR,YR),RADAR,XOR:XR=1
       61+(XU-X(3)/RX:YR=120+(YU-
       YG)/RY:PUT (XR,YR),RADAR,
       XOR
MC 610 RETURN
FE 620 REM ---------- RESPOND TO
        KEY PRESSES ----------
KP 630 CYO=CY8-5:RETURN
JB 640 CXG=CXG-5:RETURN
IL 650 CXG=CXG+5:RETURN
JN 660 CYG=CYO+5:RETURN
OB 670 FIRED=1:RETURN
LD 680 B$=" GAME STOPPED":SCORE=
       SCORE+PTS*100*L:RETURN 13
       90
KM 690 REM ---------- MOVE CROSS
        HAIRS ----------
DO 700 PUT (XG,Y(3),GD,XOR
LO 710 XG=XG+CXG:IF XG>200 THEN
       XG=200 ELSE IF XB<112 THE
       N XG=112
LD 720 YG=YG+CYG:IF YG>90 THEN Y
       G=90 ELSE IF YO<52 THEN Y
       G=52
KH 730 CXG=0:CYG=0
D6 740 PUT (XG,YO),GD,XOR
NL 750 RETURN
LA 760 REM ---------- FIRE -----
       -----
NP 770 PLAY "L64 T255 BAGFEDC <B
       ABFEDC>"
QJ 780 IF CLR THEN PUT (XU,YU),U
       FO,XOR
MG 790 LINE (160,100)-(XG+3,YG+6
       ),2
GB 800 FIRED-0 : LINE (160,100)-
      (XG+3,YG+6),0
IC 810 IF XG+3>XU AND XG+3<XU+9
       AND YB+4>YU AND YG+3<YU+6
        THEN 850
PO 820 IF CLR THEN PUT (XU,YU),U
       FO,XOR
NI 830 RETURN
JE 840 REM ---------- UFO IS HIT
        ---------
EJ 850 PUT (XG,YG),GD,XOR
CP 860 FOR E=1 TO 30:X(E)=XU+RND
       *6+1:Y(E)=YU+RND*6+1:PSET
        (X(E),Y(E)),2:SOUND 80,.
       1:NEXT E
NO 870 FOR E=1 TO 30:PRESET (X(E
       ),Y(E)):NEXT E
EL 880 IF CLR THEN PSET (XU+RND*
       6+1,YU+RND*6+1),INT(RND*4
       )
GB 890 XU=112+RND*90:YU=52+RND*4
       0:IF CLR THEN PUT(XU,YU),
       UFO,XOR
KI 900 PUT(X(B,YG),GD,XOR
FJ 910 REM ---------- ADD SCORE
DO 920 S=S+2:LINE(202,S)-(210,5)
       ,0
NN 930 PTS=PTS+1:GOSUB 970
DF 940 IF B>130 THEN PTS-PTS+1:G
       OSUB 970
EJ 950 FOR X=B TO 160 STEP 2:LIN
       E(192,X)-(200,X),0:NEXT X
       :B-160
NP 960 RETURN
BE 970 HX=112:HY=160-PTSt2:IF PT
       S>29 THEN HX-122:HY=160-(
       PTS-29)*2
QL 980 LINE (HX,HY)-(HX+B,HY),1
NF 990 RETURN
BH 1000 REM ---------- ALL UFOS
        DESTROYED - LEVEL COMPILE
        TED ----------
IP 1010 L=L+1:TL=TL-1
BO 1020 FOR P=102 TO 158 STEP 2:
        LINE(112,P)-(120,P),0:LI
        NE(122,P)-(130,P),0:NEXT
         P
BI 1030 LINE(112,52)-(209,99),0,
        BF
LI 1040 SCORE=SCORE+PTSS(L-1)410
        0
ON 1050 IF PTS<58 THEN 1140
DD 1060 PLAY "03T120 LOBBL16EELS
        EL16D+EL8EPB L16EELSEL16
        EELBGL16EGL4FL8DP8"
PO 1070 PLAY "DDL16C+DLBDL16C+DL
        8FP4 L16ED+EL88P16G16A8A
        8D3P4
KI 1080 B$=" YOU PASSED LEVEL "+
        STR$(L-1):GOSUB 250
EN 1090 PLAY "O3T120 L8GGL16EEL8
        EL16D+ELBEP8 L16EELSEL16
        EEL8GL16EGL4FLSDP8"
NA 1100 PLAY "DDL16C+DLBDL16C+DL
        4FPBL16CDEOPBL16CDESPS L
        16CDED4C4"
JC 1110 B$=STR$(1000f(L-1))+" PO
        INTS BONUS":GOSUB 250
KF 1120 FOR I=1 TO 1000:NEXT I
FN 1130 SCORE=SCORE+1000$(L-1)
OF 1140 IF L>8 THEN 1370
IE 1150 B$=" LEVEL "+STR$(L):GOS
        UB 250
FD 1160 FOR I=1 TO 500:NEXT I
QO 1170 GOTO 400
JD 1180 REM ---------- TIME'S UP
         - TAKE A HIT ----------
NA 1190 XB=XU+4:YB=YU+6:IF CLR T
        HEN PUT (XU,YU),UFO,XOR
CJ 1195 LINE(XB,YB)-(112,100),2:
        LINE (XB,YB)-(210,100),2
KJ 1200 LINE (XB,YU)-(112,52),2:
        LINE (XB,YU)-(210,52),2
FN 1210 LINE(XB,YB)-(112,100),0:
        LINE (XB,YB)-(210,100),0
QP 1220 LINE (XB,YU)-(112,52),0:
        LINE (XB,YU)-(210,52),0
BN 1225 IF CLR THEN PUT (XU,YU),
        UFO,XOR
GL 1230 FOR I=1 TO 20
DB 1240 COLOR 0,1
IA 1250 PLAY "L64 T255 BAGFEDC <
        BAGFEDC>"
DJ 1260 COLOR 0,0
HI 1270 NEXT I
PK 1280 PTS=PTS-2:IF PTS<O THEN
        PTS-0
BE 1290 IF LIVES=3 THEN 1340
GD 1300 FOR X=102 TO 158 STEP 2:
        LINE(192,X)-(200,X),O:NE
        XT X:B=160
GB 1310 LIVES=LIVES+I:LINE (151+
        4*LIVES,148)-(153+4*LIVE
        S,150),2,BF
IN 1320 RETURN
EI 1330 REM ---------- UFOS WIN
        ----------     
MN 1340 SOUND 130,0:COLOR 0,1
Q0 1350 B$=" GAME OVER":GOTO 139
        0
MJ 1360 REM ---------- SAM WINS
        ----------
KB 1370 B$=" YOU WIN !!!":GOSUB
        1460
LP 1380 GOSUB 1460
KH 1390 GOSUB 250
BE 1400 C$=" SCORE"+STRE(SCORE)
DC 1410 FOR I=1 TO 15:LOCATE 1,I
        :PRINT LEFTS(C$,40-I):NE
        XT I
CH 1420 IF INKEY$<>"" THEN 1420
IN 1430 LOCATE 23,7:INPUT "ENTER
        Y TO PLAY AGAIN: ..;R$
DN 1440 IF R$="Y" THEN RUN
II 1450 END
BB 1460 PLAY "TB003ML C4G4F16E16
        D1604C4 O3G4F16E16D1604C
        4"
OP 1470 PLAY "03G4F16E16F16D4MSC
        4"
KL 1480 RETURN


Program 2: UFO Invasion For
Amiga

Version by Philip I. Nelson,
Assistant Editor
For instructions on entering this listing, please
refer to "COMPUTE!'s Guide to Typing In
Programs" in this issue of COMPUTE!.



DEFINT A-Z←
RANDOMIZE TIMER←
SCREEN 1, 320, 200, 2, 1←
WINDOW l,"UFO Invasion",(0,0)-(3
11,185),20,1←
PALETTE 0,0,0,0←
PALETTE 1,1,1,1←
PALETTE 2,0,1,0←
PALETTE 3,1,0,0←
CLS←
DIM SH(2000),UFO(200),GD(200)←
DIM X(30),Y(30),Radar(50)←
L=1: TL=8: Lives=0: Score=0←
RX=100/15: RY=50/12←
LINE (111,51)-(211,159),3,8←
LINE (111,101)-(211,101),3←
LINE (121,1171)-(121,159),3←
LINE (131,101)-(131,159),3←
LINE (191,101)-(191,159),3←
LINE (201,101)-(201,159),3←
FOR Y=157 TO 103 STEP -2←
LINE (111,Y)-(131,Y),3←
LINE (191,Y)-(211,Y),3←
NEXT←
CIRCLE (161,1217),16,1←
CIRCLE (161,120),10,1←
CIRCLE (161,120),4,1←
LINE (146,120)-(176,120),1←
LINE (161,108)-(161,132),1←
FOR X=145 TO 173 STEP 4←
LINE (X,135)-(X+4,140),3,B←
NEXT←
FOR X=154 TO 162 STEP 4←
LINE (X,147)-(X+4,I51),3,B←
NEXT←
LINE (1,0)-(6,0),1←
LINE (0,1)-(7,1),1←
LINE (1,2)-(7,2),3←
LINE (0,3)-(7,3),1←
LINE (1,4)-(6,4),1←
GET (0,0)-(7,6),UFO←
LINE (0,0)-(7,7),0,bf←
LINE (0,3)-(4,3),2←
LINE (2,1)-(2,5),2←
GET (0,0)-(5,5),GD←
LINE (0,0)-(7,7),0,bf←
LINE (0,0)-(1,1),2,bf←
GET (0,0)-(1,1),Radar←
PUT (0,0),Radar←
GOSUB Siren←
B$=" Eneiay Alert "←
GOSUB PrintMessaye←
GOSUB Sirens
B$=" UFO Invasion "←
GOSUB Printmessages
GOTO NewLevels


PrintMessage:←
FOR J=1 TO 39←
LOCATE 1,J←
SOUND 400+(J*10),.1←
PRINT LEFT$(B$,40-J)←
NEXT←
RETURN-←


Siren:←
FOR J=1 TO 10←
FOR P=1000 TO 1900 STEP 55←
SOUND P_2←
NEXT←
NEXT←
RETURN←

Amiga Version
This photo illustrates how similar the
Amiga version of "UFO Invasion" is to
the PC/PCjr game. About 90 percent of
the code is identical to the original
program.



NewLevel:←
B=160: Pts=0: T=0←
FOR S=158 TO 102 STEP -2←
LINE (202,5)-(210,S),2←
NEXT←
IF L=3 OR L=5 OR L=7 THEN clr=0:
GOTO Mip ELSE clr=1←
FOR S=1 TO 60←
PSET(112+RND*98,52+RND*48),INT(R
ND*4)←
SOUND 1500+INT(RND(1)*11700),.1←
NEXT←
Mip:←
S=100: Xu=112+RND*90←
Yu=52+RND*40←
IF clr THEN PUT(Xu,Yu),UFO←
xg=160: yg=75←
PUT(xg,yg),GD←
LINE(142+L*4,136)-(144+L*4,139),
l,bf←


MainLoop:←
X$=INKEY$: IF UCASE$(X$)="Q" THE
N Quito
IF x$="" OR x$<CHR$(28) OR x$>CH
R$(32) THEN Skip←
ON ASC(X$)-27 GOTO Up, Down, Rig
ht, Left, Hits
GOTO Skips
Up:←
Cyg=Cyg-5:GOTO Skips
Down:←
Cyg=Cyg+5:GOTO Skip←
Right:←
Cxg=Cxg+5:GOTO Skip←
Left:←
Cxg=Cxg-5:GOTO Skip←
Hit:←
Fired=1←
Skip: ←
PUT (xg,yg),GD←
xg=xg+Cxg←
IF xg>200 THEN xg=200 ELSE IF xg
4112 THEN xg=112←
yg=yg+Cyg←
IF yg>90 THEN yg=90 ELSE IF yg<S
2 THEN yg=52←
Cxg=O:Cyg=0←
PUT (xg,yg),GD←
IF RND<.1 THEN Cxu=RND*10-5:Cyu=
RND*6-3←
IF cIr THEN PUT (Xu,Yu),UFO←
Xu=Xu+CXU←
IF Xu>200 THEN Xu=200 ELSE IF Xu
<112 THEN Xu=112←
Yu=Yu+Cyu←
IF Yu>90 THEN Yu=90 ELSE IF Yu<5
2 THEN Yu=52←
IF clr THEN PUT (Xu,Yu),UFO←
IF NotFirst THEN PUT(Xr,Yr),Rada
r←
NotFirst=1←
Xr=161+(Xu-xg)/RX←
Yr=120+(Yu-yg)/RY←
PUT (Xr,Yr),Radar←
IF Fired THEN GOSUB Shoot:IF S=1
58 THEN AllGone←
T=T+1←
IF T>TL THEN B=B-2:T=0: LINE (192,
B)-(200,B),2:IF B=102 THEN GOSUB
TakeShot←
GOTO MainLoop←


Quit:←
B$=" Game stopped"←
Score=Score+Pts*100*L←
GOTO GameOver←

Shoot:←
IF cIr THEN PUT (Xu,Yu),UFO←
LINE (160,100)-(xg+3,yg+6),2←
FOR J=50 TO 1000 STEP 200←
SOUND J, .1←
NEXT←
Fired=0←
LINE (160,100)-(xg+3,yg+6),0←
IF xg+3>Xu AND xg+3<Xu+9 AND yg+
4>Yu AND yg+3<Yu+6 THEN HitUFO←
IF clr THEN PUT (Xu,Yu),UFO←
RETURN←

H1tUFO:←
PUT (xg,yg),GD←
FOR e=1 TO 30←
X(e)=Xu+RND*6+1←
Y(e)=Yu+RND*6+1←
PSET (X(e),Y(e)),2←
SOUND 820,.1←
NEXT←
FOR e=1 TO 30←
PRESET (X(e),Y(e))←
NEXT←
IF clr THEN PSET (Xu+RND*6+1,Yu+
RND*6+1),INT(RND*4)←
Xu=112+RND*90←
Yu=52+RND*40←
IF clr THEN PUT(Xu,Yu),UFO←
PUT(xg,yg),GD←
AddScore:←
S=S+2←
LINE(202,S)-(210,5),0←
Pts=Pts+1←
GOSUB Here←
IF 8>130 THEN Pts=Pts+1:GOSUB He
re←
FOR X=B TO 160 STEP 2←
LINE(192,X)-(200,X),0←
NEXT←
B=160←
RETURN←


Here: ←
Hx=112: Hy=160-Pts*2←
IF Pts>29 THEN Hx=122:Hy=160-(Pt
s-29)*2←
LINE (Hx,Hy)-(Hx+S,Hy),1←
RETURN←


AllGone:←
L=L+1: TL=TL-1←
FOR P=102 TO 158 STEP 2←
LINE(112,P)-(120,P),0←
LINE(122,P)-(130,P),0←
NEXT←
LINE(112,52)-(209,99),0,bf←
Score=Score+Pts*(L-1)*100←
IF Pts<58 THEN GOTO There←
FOR J=500 TO 2500 STEP 500←
SOUND J,2←
NEXT←
B$=" You passed Level "+STR$(L-1
)←
GOSUB PrintMessage←
B$=STR$(1000*(L-1))+" Points bon
us"←
GOSUB PrintMessage←
FOR J=1 TO 2000←
NEXT←
Score=Score+1000*(L-1)←
IF L=9 THEN PlayerWins←
There:←
IF L>8 THEN PlayerWins←
B$=" Level "+STR$(L)←
GOSUB PrintMessage←
FOR J=1 TO 1500←
NEXT←
GOTO NewLeve1←


TakeShot:←
PUT (xg,yg),GD←
IF clr THEN PUT (Xu,Yu),UFO←
Xb=Xu+4: Yb=Yu+6←
LINE(Xb,Yb)-(112,100),2←
LINE (X0,Y0)-(210,100),2←
LINE (Xb,Yu)-(112,52),2←
LINT: (Xb,Yu)-(210,52),2←
LINE(Xb,Yb)-(112,100),0←
LINE (Xb,Yb)-(210,100),0←
LINE (Xb,Yu)-(112,52),0←
LINE (xb,Yu)-(210,52),0←
IF clr THEN PUT (Xu,Yu),UFO←
PUT (xg,yg),GD←
PALETTE 0,1,0,0←
FOR K=400 TO 500←
SOUND K,.1←
NEXT←
PALETTE 0,0,0,0←
Pts=Pts-2←
IF,Pts<O THEN Pts=0←
IF Lives=3 THEN UFOgotcha←
FOR X=102 TO 158 STEP 2←
LINE(192,X)-(200,X),0←
NEXT←
B=160←
Lives=Lives+1←
LINE (151+4*Lives,148)-(153+4*Li
ves,150),2,bf←
RETURN←


UFOgotcha:←
PALETTE 0,1,0,0←
FOR J=400 TO 500 STEP 3←
SOUND J,.1←
NEXT←
FOR J=500 TO 400 STEP -3←
SOUND J,.1←
NEXT←
PALETTE 0,0,0,0←
B$=" Game Over"←
GOTO GameOver←


PlayerWins:←
B$=" You winl"←
GOSUB WinSound←

GameOver:←
GOSUB PrintMessage←
c$= Score"+STR$(Score)←
FOR J=1 TO 15←
LOCATE 1,J←
PRINT LEFT$(c$,40-J)←
NEXT←
C1eanBuffer:←
IF INKEY$<>"" THEN C1eanBuffer←
LOCATE 23,9←
PRINT "Press Y to play again";←
X$=""←
WHILE X$=""←
X$=INKEY$←
WEND←
IF UCASE$(X$)="Y" THEN RUN←
CLS: END←


WinSound:←
FOR J=1 TO 2←
RESTORE MusicData←
SoundLoop:←
READ X←
IF X<>655356 THEN←
SOUND X,1←
GOTO SoundLoop←
END IF←
NEXT←
SOUND 550, 8←
RETURN←


MusicData:←
DATA 550, 500, 450, 400, 350←
DATA 550, 500, 450, 400, 350←
DATA 300, 350, 400, 450, 500←
DATA 65535←