(編集中)
1日で作ったパックマンのサウンド追加前のVer.です。
あと、8030行の”PAGE3S.SC5”(グラフィックとスプライトデータ)がないので、このままだとエラーで動きません(^^;
迷路作成と自機キャラクターが動くまでのプログラム
・TEST(MSX2,MSX2+,MSXturboR)
10 'PACTEST for MSX BASIC 4.0
30 GOSUB 8000
40 GOSUB 8500 'MAP
50 GOSUB 8700
100 'MAIN
110 TIME=0:ST=STICK(0)ORSTICK(1)
120 ON ST GOTO 150,150,170,170,190,190,210,210
130 ON D(0) GOTO 160,180,200
140 IF M(X(0),Y(0)-1)=7 THEN 220 ELSE 230
150 IF M(X(0),Y(0)-1)=7 THEN 130 ELSE D(0)=0:VY(0)=-1:GOTO 230
160 IF M(X(0)+1,Y(0))=7 THEN 220 ELSE 260
170 IF M(X(0)+1,Y(0))=7 THEN 130 ELSE D(0)=1:VX(0)=1:GOTO 260
180 IF M(X(0),Y(0)+1)=7 THEN 220 ELSE 230
190 IF M(X(0),Y(0)+1)=7 THEN 130 ELSE D(0)=2:VY(0)=1:GOTO 230
200 IF M(X(0)-1,Y(0))=7 THEN 220 ELSE 240
210 IF M(X(0)-1,Y(0))=7 THEN 130 ELSE D(0)=3:VX(0)=-1:GOTO 240
220 VX(0)=0:VY(0)=0:GOTO 300
230 Y(0)=Y(0)+VY(0):SY(0)=SY(0)+VY(0)*8:GOTO 280
240 IF X(0)=1 THEN X(0)=22:SX(0)=22*8-4
250 GOTO 270
260 IF X(0)=21 THEN X(0)=0:SX(0)=-4
270 X(0)=X(0)+VX(0):SX(0)=SX(0)+VX(0)*8
280 MM(0)=(MM(0)+1)MOD4
290 IF M(X(0),Y(0))=1 THEN CL=CL+1:M(X(0),Y(0))=0:COPY(0,48)-(7,55),3TO(X(0)*8,Y(0)*8):IF SE=0 THEN SE=1
300 PUT SPRITE 0,(SX(0),SY(0)),,A(0,D(0)*4+MM(0))
710 FOR I=1 TO 4
720 MM(I)=MM(I)XOR1
730 PUT SPRITE I*2,(SX(I),SY(I)),,20+D(I)*2+MM(I):PUT SPRITE I*2+1,(SX(I),SY(I)),,28+D(I)*2
740 NEXT
900 IF TIME<10 THEN 900 ELSE 110
8000 '
8010 DEFINT A-Z:SCREEN 5,2:COLOR15,1,1
8020 DIM M(22,25),X(4),Y(4),SX(9),SY(9),D(4),A(4,15)
8030 SET PAGE 0,3:BLOAD"PAGE3S.SC5",S
8040 COLOR=RESTORE
8050 'SPRITE COPY
8060 VDP(34)=0:VDP(38)=0:VDP(42)=0:VDP(44)=0:VDP(46)=0
8070 VDP(33)=0:VDP(35)=72:VDP(36)=3:VDP(37)=0:VDP(39)=240:VDP(40)=0:VDP(41)=255:VDP(43)=16:VDP(47)=208
8080 ONVDP(-2)AND1GOTO 8080
8200 'PAC SPRITE
8210 RESTORE 9610:FOR I=0 TO 15:READ A(0,I):NEXT
8220 RETURN
8500 'MAP
8510 RESTORE 9010:SET PAGE 0,0:CLS
8520 FOR Y=0 TO 25:READ B$
8530 FOR X=1 TO 21:A=VAL("&H"+MID$(B$,X,1))
8540 COPY(A*8,64)-(A*8+7,64+7),3TO(X*8,Y*8),0
8550 IF A>1 THEN A=7
8560 M(X,Y)=A
8570 NEXT:NEXT
8580 CL=0:M(12,8)=3:M(10,8)=3
8660 RETURN
8700 'SETTING
8710 X(0)=11:Y(0)=19:D(0)=3:VX(0)=-1:MM(0)=0:MS=0:TI=0:SS=1
8720 X(1)=11:Y(1)=9:D(1)=3:X(2)=11:Y(2)=12:D(2)=0:X(3)=10:Y(3)=12:D(3)=2:X(4)=12:Y(4)=12:D(4)=2
8730 FOR I=0 TO 4:SX(I)=X(I)*8-4:SY(I)=Y(I)*8-5:NEXT
8740 COLOR SPRITE$(0)=STRING$(16,&H6)
8750 COLOR SPRITE$(2)=STRING$(16,&H8)
8760 COLOR SPRITE$(4)=STRING$(16,&H9)
8770 COLOR SPRITE$(6)=STRING$(16,&HA)
8780 COLOR SPRITE$(8)=STRING$(16,&HB)
8790 COLOR SPRITE$(3)=STRING$(16,&H47)
8800 COLOR SPRITE$(5)=STRING$(16,&H47)
8810 COLOR SPRITE$(7)=STRING$(16,&H47)
8820 COLOR SPRITE$(9)=STRING$(16,&H47)
8830 PUT SPRITE 0,(SX(0),SY(0)),,0
8840 FOR I=1 TO 4
8850 PUT SPRITE I*2,(SX(I),SY(I)),,20+D(I)*2+MM(I):PUT SPRITE I*2+1,(SX(I),SY(I)),,28+D(I)*2
8860 NEXT
8890 RETURN
9000 'MAP DATA
9010 ' "012345678901234567890
9020 DATA "433333333383333333335
9030 DATA "211111111121111111112
9040 DATA "214351435121435143512
9050 'ATA "212021202121202120212
9060 DATA "2163716371C1637163712
9070 DATA "211111111111111111112
9080 DATA "214351D1433351D143512
9090 DATA "216371216383712163712
9100 DATA "211111211121112111112
9110 DATA "633351A3E0C0F3B143337
9120 DATA "000021200000002120000
9130 DATA "000021204E3F502120000
9140 DATA "F33371C0200020C16333E
9150 DATA "000001002000200100000
9160 DATA "F33351D0633370D14333E
9170 DATA "000021200000002120000
9180 DATA "000021204333502120000
9190 DATA "433371C0638370C163335
9200 DATA "211111111121111111112
9210 DATA "21F351F3E1C1F3E143E12
9220 DATA "211121111101111121112
9230 DATA "A35121D1433351D12143B
9240 DATA "A371C12163837121C163B
9250 DATA "211111211121112111112
9260 DATA "21F33393E1C1F39333E12
9270 DATA "211111111111111111112
9280 DATA "633333333333333333337
9600 '
9610 DATA 0,1,2,1,0,3,4,3,0,5,6,5,0,7,8,7
敵キャラクター、ミス処理、クリア処理などの追加プログラム
・FIX(MSX2,MSX2+,MSX turboR)
400 ON SS GOSUB 2010,2020,2030
410 FOR I=1 TO 4:IF TI<500 THEN GOSUB 2500:GOTO 500
420 ON I GOTO 430,440,450,460
430 X=X(0):Y=Y(0):GOTO 500
440 X=X(0)+(D(0)=3)*3-(D(0)=1)*3:Y=Y(0)+(D(0)=0)*3-(D(0)=2)*3:GOTO 470
450 X=X(0)+X(0)-X(1):Y=Y(0)+Y(0)-Y(1):GOTO 470
460 IF ABS(X(4)-X(0))<5 AND ABS(Y(4)-Y(0))<5 THEN 450 ELSE 430
470 IF X<1 THEN X=1 ELSE IF X>22 THEN X=22
480 IF Y<1 THEN Y=1 ELSE IF Y>24 THEN Y=24
500 X=X(I)-X:Y=Y(I)-Y:VX(I)=0:VY(I)=0:J=-1
510 ON D(I) GOTO 540,560,580
520 IF Y>0 THEN P(0)=D(I):IF X>0 THEN P(1)=3:P(2)=1:GOTO 600 ELSE P(1)=1:P(2)=3:GOTO 600
530 P(2)=D(I):IF X>0 THEN P(0)=3:P(1)=1:GOTO 600 ELSE P(0)=1:P(1)=3:GOTO 600
540 IF X<0 AND ABS(X)>ABS(Y) THEN P(0)=D(I):IF Y>0 THEN P(1)=0:P(2)=2:GOTO 600 ELSE P(1)=2:P(2)=0:GOTO 600
550 P(2)=D(I):IF Y>0 THEN P(0)=0:P(1)=2:GOTO 600 ELSE P(0)=2:P(1)=0:GOTO 600
560 IF Y<0 THEN P(0)=D(I):IF X>0 THEN P(1)=3:P(2)=1:GOTO 600 ELSE P(1)=1:P(2)=3:GOTO 600
570 P(2)=D(I):IF X>0 THEN P(0)=3:P(1)=1:GOTO 600 ELSE P(0)=1:P(1)=3:GOTO 600
580 IF X>0 AND ABS(X)>ABS(Y) THEN P(0)=D(I):IF Y>0 THEN P(1)=0:P(2)=2:GOTO 600 ELSE P(1)=2:P(2)=0:GOTO 600
590 P(2)=D(I):IF Y>0 THEN P(0)=0:P(1)=2:GOTO 600 ELSE P(0)=2:P(1)=0:GOTO 600
600 J=(J+1)MOD4:ON P(J) GOTO 620,630,640
610 IF M(X(I),Y(I)-1)>2 THEN 600 ELSE D(I)=0:VY(I)=-1:GOTO 650
620 IF M(X(I)+1,Y(I))>4 THEN 600 ELSE D(I)=1:VX(I)=1:GOTO 680
630 IF M(X(I),Y(I)+1)>4 THEN 600 ELSE D(I)=2:VY(I)=1:GOTO 650
640 IF M(X(I)-1,Y(I))>4 THEN 600 ELSE D(I)=3:VX(I)=-1:GOTO 660
650 Y(I)=Y(I)+VY(I):SY(I)=SY(I)+VY(I)*8:GOTO 660
660 IF X(I)=1 THEN X(I)=22:SX(I)=22*8-4
670 GOTO 690
680 IF X(I)=21 THEN X(I)=0:SX(I)=-4
690 X(I)=X(I)+VX(I):SX(I)=SX(I)+VX(I)*8
700 NEXT
710 FOR I=1 TO 4
720 MM(I)=MM(I)XOR1
730 PUT SPRITE I*2,(SX(I),SY(I)),,20+D(I)*2+MM(I):PUT SPRITE I*2+1,(SX(I),SY(I)),,28+D(I)*2
740 NEXT
800 FOR I=1 TO 4
810 IF ABS(X(I)-X(0))+ABS(Y(I)-Y(0))<2 THEN MS=1
820 NEXT
830 IF CL=186 THEN 7000
840 IF MS=1 THEN 6000
900 IF TIME<10 THEN 900 ELSE TI=(TI+TIME)MOD30000:GOTO 110
2000 '
2010 IF TI>200 AND SS=1 THEN SS=2:GOTO 2050 ELSE RETURN
2020 IF TI>400 AND SS=2 THEN SS=3:GOTO 2050 ELSE RETURN
2030 IF TI>600 AND SS=3 THEN SS=4:GOSUB 2050:SS=0
2040 RETURN
2050 D(SS)=3:X(SS)=12:Y(SS)=9:SX(SS)=X(SS)*8-4:SY(SS)=Y(SS)*8-5:RETURN
2500 '
2510 ON I GOTO 2520,2530,2540,2550
2520 X=20:Y=2:RETURN
2530 X=2:Y=2:RETURN
2540 X=2:Y=18:RETURN
2550 X=20:Y=18:RETURN
6000 ' MISS
6010 INTERVAL OFF:TIME=0
6020 IF TIME<60 THEN 6020 ELSE FOR I=1 TO 4:PUT SPRITEI*2,(0,219):NEXT:I=9
6030 FOR J=0 TO 10:GOSUB 6200:NEXT
6140 IF TIME<60 THEN 6140 ELSE 50
6200 TIME=0:PUT SPRITE0,(SX(0),SY(0)),,I
6210 IF TIME<4 THEN 6210 ELSE I=I+1:RETURN
7000 'CLEAR
7010 INTERVAL OFF:TIME=0:I=0
7020 IF TIME<60 THEN 7020
7030 FOR I=1 TO 4:PUT SPRITEI*2,(0,219):NEXT
7040 TIME=0
7050 IF TIME<15 THEN 7050 ELSE I=I+1:ON IMOD2+1 GOSUB 7100,7110
7060 IF I<11 THEN 7040 ELSE PUT SPRITE0,(0,219)
7080 END
7100 COLOR=(12,7,7,7):RETURN
7110 COLOR=(12,0,0,7):RETURN
0 件のコメント:
コメントを投稿