2

« Last post by **SRS ** on* ***Today** at 15:41 »
Just for fun I added a part that deletes old explosion clouds after roundabout 4 seconds:

`100 ' Setup Inks and Screen Mode`

110 INK 0,0

120 INK 1,26

130 INK 2,20

140 INK 3,18

150 BORDER 11

160 PAPER 0

170 PEN 1

180 MODE 1

190 ' Define Characters & Objects

200 DEFINT a-z

210 s$=CHR$(143)

220 a$="@"

230 b$="-"

240 x=1

250 y=1

260 DIM bx(2)

270 DIM by(2)

280 b=1

290 t=0

300 sc=0

310 ay=1+INT(RND*23)

320 ax=37

330 GOSUB 600 ' Print Ship

340 GOSUB 690 ' Print Alien

350 LOCATE 1,25

360 PRINT"Score:"

370 ' Main Loop

380 WHILE 1

390 IF INKEY(1)<>-1 AND x<30 THEN GOSUB 650:x=x+1:GOSUB 600

400 IF INKEY(<>-1 AND x>1 THEN GOSUB 650:x=x-1:GOSUB 600

410 IF INKEY(0)<>-1 AND y>1 THEN GOSUB 650:y=y-1:GOSUB 600

420 IF INKEY(2)<>-1 AND y<24 THEN GOSUB 650:y=y+1:GOSUB 600

430 GOSUB 570

440 GOSUB 820 : GOSUB 690 ' Delete & Reprint Alien

450 GOSUB 500

460 IF INKEY(47)<>-1 AND t<>2 THEN t=t+1:bx(t)=x+1:by(t)=y

470 IF t<>0 THEN GOSUB 860

480 WEND

490 ' Has bullet or alien collided?

500 IF by(1)<>ay THEN IF by(2)<>ay THEN GOSUB 860:RETURN:ELSE GOSUB 510:RETURN

510 FOR n1=1 TO t

520 IF bx(n1)=ax THEN GOSUB 990

530 IF bx(n1)+1=ax THEN LOCATE bx(n1),by(n1):PRINT" ";:bx(n1)=bx(n1)+1:LOCATE bx(n1),by(n1):PRINT b$;:GOSUB 990

540 NEXT n1

550 RETURN

560 ' Has Alien Collided with Ship?

570 IF (x=ax) AND (y=ay) THEN GOSUB 990:LOCATE 15,12:PRINT"You're Dead!":END

580 RETURN

590 ' Display Ship

600 LOCATE x,y

610 PEN 1

620 PRINT s$;

630 RETURN

640 ' Delete Ship

650 LOCATE x,y

660 PRINT" ";

670 RETURN

680 ' Display and Move Alien

690 LOCATE ax,ay

700 PEN 2

710 PRINT a$;

720 ax=ax-1

730 GOSUB 570

740 WHILE ax=0

750 LOCATE 1,ay

760 PRINT" ";

770 ax=37

780 ay=1+INT(RND*23)

790 WEND

800 ' GOSUB 610

810 RETURN

820 LOCATE ax+1,ay

830 PRINT" ";

840 RETURN

850 ' Routine to Move Shots Fired

860 FOR n=b TO t

870 LOCATE bx(n),by(n)

880 PRINT" ";

890 PEN 3

900 bx(n)=bx(n)+1

910 LOCATE bx(n),by(n)

920 PRINT b$;

930 IF bx(n)=38 THEN LOCATE 38,by(n):PRINT" ";:b=b+1

940 NEXT n

950 IF bx(n-1)=38 AND b=3 THEN GOSUB 1180

960 ' GOSUB 610

970 RETURN

980 ' Death Sequence for Alien or Ship should they Collide

990 LOCATE ax,ay

1000 ex=ax:ey=ay:AFTER 200 GOSUB 1210

1010 PRINT" ";CHR$(238);

1020 sc=sc+20

1030 LOCATE 8,25

1040 PRINT sc;

1050 ax=39

1060 ay=1+INT(RND*23)

1070 FOR v=15 TO 0 STEP -1

1080 BORDER 6

1090 SOUND 1,0,3,v,,,31

1100 BORDER 11

1110 SOUND 2,1000,3,v,,,31

1120 NEXT v

1130 FOR c=1 TO t

1140 LOCATE bx(c),by(c)

1150 PRINT" ";

1160 bx(c)=0:by(c)=0

1170 NEXT c

1180 b=1:t=0

1190 RETURN

1200 ' Delete old explosion

1210 LOCATE ex,ey:PRINT " ";

1220 RETURN