投稿者:しばっち
投稿日:2014年11月 6日(木)19時37分23秒
|
|
|
ただの迷路ゲームです。
スタート地点「座標(1,1)左上」から、ゴール地点「座標(79,79)右下」を目指します。
表示画面の緑のボタンをマウスで左クリックします。
MAP表示 3回まで(緑の点が現在位置)
現在位置 2回まで表示。
「前」ボタン左クリックで"上"に進みます。
PUBLIC NUMERIC XSIZE,YSIZE,XS(4),YS(4),LOC,HELP,LT,FL,XX,YY,R,RR,TI,TY,MX,MY
PUBLIC STRING Z$(4)
LET XSIZE=700
LET YSIZE=700
CALL GINIT(XSIZE,YSIZE)
LET M=40 !'迷路サイズ 2*M*2*N
LET N=40
LET HELP=3 !'MAP表示回数
LET LOC=2 !'現在位置表示回数
DIM MAP(0 TO 2*M,0 TO 2*N)
FOR I=1 TO 4
READ XS(I),YS(I),Z$(I)
NEXT I
DATA 0,-1,上
DATA -1,0,左
DATA 0,1,下
DATA 1,0,右
CALL MAKEMAZE(MAP,M,N)
IF MAP(1,1)<>0 OR MAP(2*M-1,2*N-1)<>0 THEN STOP !'エラー
LET TY=INT(TIME)
DO
LOOP WHILE TY=INT(TIME)
LET TY=INT(TIME)
LET XX=1
LET YY=1
LET R=1
DO
LET I0=-3
LET I1=3
LET J0=-3
LET J1=3
LET Y=50
SELECT CASE R !'画面表示
CASE 1,3
IF R=3 THEN
SWAP I0,I1
SWAP J0,J1
END IF
FOR I=I0 TO I1 STEP SGN(I1-I0)
LET X=XSIZE/2-175
FOR J=J0 TO J1 STEP SGN(J1-J0)
IF XX+J>=0 AND YY+I>=0 AND XX+J<=2*M AND YY+I<=2*N THEN
LET C=MAP(XX+J,YY+I)
IF C=2 THEN LET C=0
CALL BOXFULL(X,Y,X+50,Y+50,C)
IF XX+J=2*M-1 AND YY+I=2*N-1 THEN
SET TEXT HEIGHT 50
SET TEXT COLOR 6
SET TEXT JUSTIFY "LEFT","TOP"
PLOT TEXT,AT X,Y:"G" !'ゴール目印
END IF
ELSE
CALL BOXFULL(X,Y,X+50,Y+50,7)
END IF
LET X=X+50
NEXT J
LET Y=Y+50
NEXT I
CASE 2,4
IF R=2 THEN
SWAP J0,J1
ELSE
SWAP I0,I1
END IF
FOR I=I0 TO I1 STEP SGN(I1-I0)
LET X=XSIZE/2-175
FOR J=J0 TO J1 STEP SGN(J1-J0)
IF XX+I>=0 AND YY+J>=0 AND XX+I<=2*N AND YY+J<=2*M THEN
LET C=MAP(XX+I,YY+J)
IF C=2 THEN LET C=0
CALL BOXFULL(X,Y,X+50,Y+50,C)
IF XX+I=2*M-1 AND YY+J=2*N-1 THEN
SET TEXT HEIGHT 50
SET TEXT COLOR 6
SET TEXT JUSTIFY "LEFT","TOP"
PLOT TEXT,AT X,Y:"G"
END IF
ELSE
CALL BOXFULL(X,Y,X+50,Y+50,7)
END IF
LET X=X+50
NEXT J
LET Y=Y+50
NEXT I
END SELECT
CALL BOX(XSIZE/2-175,50,XSIZE/2+175,400,2)
CALL PUTCHARACTER(XSIZE/2-25,200,1.5)
CALL DISPLOC
IF LOC=0 AND FM=0 THEN
CALL BOXFULL(0,YSIZE-150,150,YSIZE,0)
LET FM=1
END IF
CALL DISPTIME
IF XX=2*M-1 AND YY=2*N-1 THEN !'ゴール到達
SET TEXT HEIGHT 70
SET TEXT COLOR 6
SET TEXT JUSTIFY "LEFT","TOP"
PLOT TEXT ,AT 20,50:"Congratulations"
STOP
END IF
IF HELP<>HH OR LOC<>LL THEN
CALL BOXFULL(0,250,160,350,0)
SET TEXT JUSTIFY "LEFT","TOP"
SET TEXT HEIGHT 20
PLOT TEXT ,AT 0,250:"MAP 残 "&STR$(HELP)
PLOT TEXT ,AT 0,280:"位置 残 "&STR$(LOC)
LET HH=HELP
LET LL=LOC
END IF
LET S$=GETKEY$(XSIZE/2,YSIZE-150,100)
IF S$<>"" THEN WAIT DELAY .1
IF S$="4" THEN LET R=R+1
IF S$="6" THEN LET R=R-1
IF S$="2" THEN LET R=R+2
IF R>4 THEN LET R=R-4
IF R<1 THEN LET R=R+4
IF S$="8" AND MAP(XX+XS(R),YY+YS(R))<>7 THEN
LET XX=XX+XS(R)
LET YY=YY+YS(R)
END IF
IF S$="M" AND HELP>0 THEN !'MAP表示
CALL DISPLAYMAP(MAP,M,N,XX,YY)
LET TT=INT(TIME)
DO
LOOP WHILE TT=INT(TIME)
LET TT=INT(TIME)
DO
MOUSE POLL DMX,DMY,LEFT,RIGHT
LOOP UNTIL INT(TIME)-TT>=HELP*4 OR LEFT=1 OR RIGHT=1 !'クリックするか、時間待ち
CLEAR
LET HELP=HELP-1
END IF
IF S$="L" THEN
LET LT=INT(TIME)
LET FL=0
LET LOC=LOC-1
END IF
IF XX<0 THEN LET XX=0
IF YY<0 THEN LET YY=0
IF XX>2*M THEN LET XX=2*M
IF YY>2*N THEN LET YY=2*N
LET MAP(XX,YY)=2 !'足跡を残す(赤色)
LOOP
END
EXTERNAL SUB MAKEMAZE(MAP(,),M,N) !'迷路作成
RANDOMIZE
MAT MAP=ZER
LET S=(M-1)*(N-1)
FOR I=0 TO 2*M
LET MAP(I,0)=7
LET MAP(I,2*N)=7
NEXT I
FOR I=0 TO 2*N
LET MAP(0,I)=7
LET MAP(2*M,I)=7
NEXT I
DO
DO
LET X=INT(RND*(M+1))
LET Y=INT(RND*(N+1))
LET X0=X*2
LET Y0=Y*2
LOOP WHILE MAP(X0,Y0)=0
LET R=INT(RND*4)+1
LET XN=X0+XS(R)*2
LET YN=Y0+YS(R)*2
IF XN>0 AND XN<2*M AND YN>0 AND YN<2*N AND MAP(XN,YN)=0 THEN
IF X0=XN THEN
FOR K=Y0 TO YN STEP SGN(YN-Y0)
LET MAP(X0,K)=7
NEXT K
ELSE
FOR K=X0 TO XN STEP SGN(XN-X0)
LET MAP(K,Y0)=7
NEXT K
END IF
LET X0=XN
LET Y0=YN
LET S=S-1
END IF
LOOP WHILE S>0
END SUB
EXTERNAL SUB DISPLAYMAP(MAP(,),M,N,XX,YY) !'地図表示
CLEAR
FOR I=0 TO 2*N
FOR J=0 TO 2*M
LET C=MAP(J,I)
IF J=XX AND I=YY THEN LET C=4 !'現在の位置(緑)
IF J=2*M-1 AND I=2*N-1 THEN LET C=6 !'ゴール(黄)
CALL BOXFULL(J*XSIZE/(2*M+1),I*YSIZE/(2*N+1),(J+1)*XSIZE/(2*M+1),(I+1)*YSIZE/(2*N+1),C)
NEXT J
NEXT I
END SUB
EXTERNAL SUB GINIT(XSIZE,YSIZE)
SET BITMAP SIZE XSIZE,YSIZE
SET WINDOW 0,XSIZE-1,YSIZE-1,0
SET POINT STYLE 1
SET COLOR MODE "REGULAR"
SET COLOR MIX(0) 0,0,0
SET COLOR MIX(1) 0,0,1
SET COLOR MIX(2) 1,0,0
SET COLOR MIX(3) 1,0,1
SET COLOR MIX(4) 0,1,0
SET COLOR MIX(5) 0,1,1
SET COLOR MIX(6) 1,1,0
SET COLOR MIX(7) 1,1,1
SET COLOR MIX(242) 112/255,40/255,24/255
SET COLOR MIX(243) 8/255,40/255,56/255
SET COLOR MIX(244) 248/255,112/255,64/255
SET COLOR MIX(245) 40/255,88/255,248/255
SET COLOR MIX(246) 192/255,56/255,32/255
SET COLOR MIX(247) 248/255,248/255,248/255
SET COLOR MIX(248) 0/255,48/255,168/255
SET COLOR MIX(249) 192/255,104/255,80/255
SET COLOR MIX(250) 88/255,56/255,24/255
SET COLOR MIX(251) 248/255,200/255,184/255
SET COLOR MIX(252) 192/255,128/255,40/255
SET COLOR MIX(253) 144/255,144/255,160/255
SET COLOR MIX(254) 80/255,48/255,24/255
SET COLOR MIX(255) 248/255,208/255,88/255
CLEAR
END SUB
EXTERNAL SUB BOXFULL(X1,Y1,X2,Y2,C)
SET AREA COLOR C
PLOT AREA:X1,Y1;X2,Y1;X2,Y2;X1,Y2;X1,Y1
END SUB
EXTERNAL SUB BOX(XS,YS,XE,YE,C)
CALL LINE(XS,YS,XE,YS,C)
CALL LINE(XE,YS,XE,YE,C)
CALL LINE(XE,YE,XS,YE,C)
CALL LINE(XS,YE,XS,YS,C)
END SUB
EXTERNAL SUB LINE(XS,YS,XE,YE,C)
SET LINE COLOR C
PLOT LINES
PLOT LINES:XS,YS;XE,YE
END SUB
EXTERNAL FUNCTION AREA3(X1,Y1,X2,Y2,X3,Y3,PX,PY) !'PX,PYが三角形内か
LET T=TRIANGLE(X1,Y1,X2,Y2,X3,Y3)
LET A=TRIANGLE(X1,Y1,X2,Y2,PX,PY)
LET B=TRIANGLE(X2,Y2,X3,Y3,PX,PY)
LET C=TRIANGLE(X1,Y1,X3,Y3,PX,PY)
IF A+B+C=T THEN LET AREA3=-1 ELSE LET AREA3=0
END FUNCTION
EXTERNAL FUNCTION AREA4(X1,Y1,X2,Y2,X3,Y3,X4,Y4,PX,PY)
LET A=AREA3(X1,Y1,X2,Y2,X3,Y3,PX,PY)
IF A<>0 THEN
LET AREA4=-1
EXIT FUNCTION
END IF
LET B=AREA3(X1,Y1,X4,Y4,X3,Y3,PX,PY)
IF B<>0 THEN LET AREA4=-1 ELSE LET AREA4=0
END FUNCTION
EXTERNAL FUNCTION TRIANGLE(X1,Y1,X2,Y2,X3,Y3) !'三角形の面積
LET TRIANGLE=ABS(X1*Y2+X2*Y3+X3*Y1-X2*Y1-X3*Y2-Y3*X1)/2
END FUNCTION
EXTERNAL FUNCTION GETKEY$(X,Y,SIZE) !'マウス入力
SET AREA COLOR 4
SET TEXT COLOR 7
PLOT AREA:X,Y-SIZE;X-SIZE,Y;X,Y+SIZE;X+SIZE,Y
IF HELP>0 THEN PLOT AREA:XSIZE-150,YSIZE-150;XSIZE,YSIZE-150;XSIZE,YSIZE;XSIZE-150,YSIZE
IF LOC>0 THEN PLOT AREA:0,YSIZE-150;150,YSIZE-150;150,YSIZE;0,YSIZE
CALL LINE(X-SIZE/2,Y-SIZE/2,X+SIZE/2,Y+SIZE/2,7)
CALL LINE(X+SIZE/2,Y-SIZE/2,X-SIZE/2,Y+SIZE/2,7)
SET TEXT JUSTIFY "CENTER","HALF"
SET TEXT HEIGHT SIZE/3
LET X1=X-SIZE/2
LET Y1=Y-SIZE/2
LET X2=X1
LET Y2=Y+SIZE/2
LET X3=X+SIZE/2
LET Y3=Y2
LET X4=X3
LET Y4=Y1
PLOT TEXT ,AT X,Y-SIZE/2: "前"
PLOT TEXT ,AT X-SIZE/2,Y: "左"
PLOT TEXT ,AT X+SIZE/2,Y: "右"
PLOT TEXT ,AT X,Y+SIZE/2: "後"
IF HELP>0 THEN PLOT TEXT ,AT XSIZE-75,YSIZE-75:"MAP"
IF LOC>0 THEN
SET TEXT JUSTIFY "LEFT","HALF"
SET TEXT HEIGHT SIZE/4
PLOT TEXT ,AT 0,YSIZE-75:"現在位置"
END IF
SET AREA COLOR 2
SET TEXT JUSTIFY "CENTER","HALF"
LET GETKEY$=""
DO
MOUSE POLL X0,Y0,LEFT,RIGHT
LOOP WHILE LEFT=1 OR RIGHT=1
DO
CALL DISPTIME
CALL DISPLOC
MOUSE POLL X0,Y0,LEFT,RIGHT
LOOP UNTIL LEFT=1 OR RIGHT=1
IF AREA4(X,Y-SIZE,X1,Y1,X,Y,X4,Y4,X0,Y0)<>0 AND LEFT=1 THEN
PLOT AREA :X,Y-SIZE;X1,Y1;X,Y;X4,Y4
PLOT TEXT ,AT X,Y-SIZE/2: "前"
LET GETKEY$="8"
END IF
IF AREA4(X1,Y1,X-SIZE,Y,X2,Y2,X,Y,X0,Y0)<>0 AND LEFT=1 THEN
PLOT AREA :X1,Y1;X-SIZE,Y;X2,Y2;X,Y
PLOT TEXT ,AT X-SIZE/2,Y: "左"
LET GETKEY$="4"
END IF
IF AREA4(X,Y,X2,Y2,X,Y+SIZE,X3,Y3,X0,Y0)<>0 AND LEFT=1 THEN
PLOT AREA :X,Y;X2,Y2;X,Y+SIZE;X3,Y3
PLOT TEXT ,AT X,Y+SIZE/2: "後"
LET GETKEY$="2"
END IF
IF AREA4(X4,Y4,X,Y,X3,Y3,X+SIZE,Y,X0,Y0)<>0 AND LEFT=1 THEN
PLOT AREA :X4,Y4;X,Y;X3,Y3;X+SIZE,Y
PLOT TEXT ,AT X+SIZE/2,Y: "右"
LET GETKEY$="6"
END IF
IF HELP>0 AND AREA4(XSIZE-150,YSIZE-150,XSIZE,YSIZE-150,XSIZE,YSIZE,XSIZE-150,YSIZE,X0,Y0)<>0 AND LEFT=1 THEN
PLOT AREA :XSIZE-150,YSIZE-150;XSIZE,YSIZE-150;XSIZE,YSIZE;XSIZE-150,YSIZE
PLOT TEXT ,AT XSIZE-75,YSIZE-75:"MAP"
LET GETKEY$="M"
END IF
IF LOC>0 AND AREA4(0,YSIZE-150,150,YSIZE-150,150,YSIZE,0,YSIZE,X0,Y0)<>0 AND LEFT=1 THEN
PLOT AREA :0,YSIZE-150;150,YSIZE-150;150,YSIZE;0,YSIZE
SET TEXT JUSTIFY "LEFT","HALF"
PLOT TEXT ,AT 0,YSIZE-75:"現在位置"
LET GETKEY$="L"
END IF
END FUNCTION
EXTERNAL SUB DISPTIME !'時間表示
IF INT(TIME)<>TI THEN
LET TI=INT(TIME)
CALL BOXFULL(XSIZE-150,200,XSIZE,300,0)
SET TEXT COLOR 7
SET TEXT HEIGHT 20
SET TEXT JUSTIFY "LEFT","TOP"
PLOT TEXT ,AT XSIZE-150,200:"経過時間"
PLOT TEXT ,AT XSIZE-100,240:STR$(INT(TIME-TY))&"s"
END IF
END SUB
EXTERNAL SUB DISPLOC !'位置表示
IF INT(TIME)-LT<55 THEN LET C=7 ELSE LET C=2
IF LOC>0 AND INT(TIME)-LT<60 AND (MX<>XX OR MY<>YY OR R<>RR) THEN
SET TEXT COLOR C
SET TEXT HEIGHT 20
SET TEXT JUSTIFY "LEFT","TOP"
CALL BOXFULL(XSIZE-150,40,XSIZE,120,0)
PLOT TEXT ,AT XSIZE-150,40:"現在位置"
PLOT TEXT ,AT XSIZE-120,80:"("&STR$(XX)&","&STR$(YY)&")"
CALL BOXFULL(0,0,140,140,0)
CALL LINE(50,80,110,80,C)
CALL LINE(80,50,80,110,C)
SET TEXT JUSTIFY "CENTER","HALF"
PLOT TEXT ,AT 40,80:Z$(MOD(R,4)+1)
PLOT TEXT ,AT 120,80:Z$(MOD(R+2,4)+1)
PLOT TEXT ,AT 80,40:Z$(R)
PLOT TEXT ,AT 80,120:Z$(MOD(R+1,4)+1)
LET MX=XX
LET MY=YY
LET RR=R
END IF
IF INT(TIME)-LT>60 AND FL=0 THEN
CALL BOXFULL(XSIZE-150,0,XSIZE,120,0)
CALL BOXFULL(0,0,140,140,0)
LET FL=1
END IF
END SUB
EXTERNAL SUB PUTCHARACTER(XX,YY,SIZE)
LET X=XX
LET Y=YY
DO
READ IF MISSING THEN EXIT DO: A$
FOR J=1 TO LEN(A$) STEP 2
LET C=BVAL(A$(J:J+1),16)
CALL BOXFULL(X,Y,X+SIZE,Y+SIZE,C)
LET X=X+SIZE
NEXT J
LET X=XX
LET Y=Y+SIZE
LOOP
DATA "0000F2F2000000000000F3F3F2F2F4F4F4F4F2F2F3F3000000000000F2F20000"
DATA "0000F2F2000000000000F3F3F2F2F4F4F4F4F2F2F3F3000000000000F2F20000"
DATA "F2F2F4F4F2F20000F3F3F5F5F5F5F4F4F4F4F5F5F5F5F3F30000F2F2F4F4F2F2"
DATA "F2F2F4F4F2F20000F3F3F5F5F5F5F4F4F4F4F5F5F5F5F3F30000F2F2F4F4F2F2"
DATA "F2F2F4F4F4F4F2F2F5F5F3F3F3F3F3F3F3F3F3F3F3F3F5F5F2F2F4F4F4F4F2F2"
DATA "F2F2F4F4F4F4F2F2F5F5F3F3F3F3F3F3F3F3F3F3F3F3F5F5F2F2F4F4F4F4F2F2"
DATA "F2F2F6F6F4F4F7F7F3F3F5F5F5F5F5F5F5F5F5F5F5F5F3F3F4F4F4F4F6F6F2F2"
DATA "F2F2F6F6F4F4F7F7F3F3F5F5F5F5F5F5F5F5F5F5F5F5F3F3F4F4F4F4F6F6F2F2"
DATA "0000F2F2F4F4F7F7F8F8F5F5F3F3F3F3F3F3F3F3F5F5F8F8F4F4F4F4F2F20000"
DATA "0000F2F2F4F4F7F7F8F8F5F5F3F3F3F3F3F3F3F3F5F5F8F8F4F4F4F4F2F20000"
DATA "0000F2F2F6F6F7F7F3F3F8F8F8F8F8F8F8F8F8F8F8F8F3F3F6F6F6F6F2F20000"
DATA "0000F2F2F6F6F7F7F3F3F8F8F8F8F8F8F8F8F8F8F8F8F3F3F6F6F6F6F2F20000"
DATA "00000000F2F2F7F7F8F8F9F9FAFAFBFBFBFBFAFAF9F9F8F8F2F2F2F200000000"
DATA "00000000F2F2F7F7F8F8F9F9FAFAFBFBFBFBFAFAF9F9F8F8F2F2F2F200000000"
DATA "000000000000F7F7F9F9FBFBFAFAF9F9F9F9FAFAF9F9F9F9F3F3000000000000"
DATA "000000000000F7F7F9F9FBFBFAFAF9F9F9F9FAFAF9F9F9F9F3F3000000000000"
DATA "000000000000F7F7F3F3FBFBFBFBFBFBFBFBFBFBF9F9F8F8F5F5FCFC00000000"
DATA "000000000000F7F7F3F3FBFBFBFBFBFBFBFBFBFBF9F9F8F8F5F5FCFC00000000"
DATA "00000000F2F2FDFDF8F8FEFEFBFBFBFBFBFBF9F9FEFEF5F5FFFFF8F8F2F20000"
DATA "00000000F2F2FDFDF8F8FEFEFBFBFBFBFBFBF9F9FEFEF5F5FFFFF8F8F2F20000"
DATA "0000F2F2FFFFFFFFFCFCF5F5FEFEFEFEFEFEFEFEFFFFFFFFF5F5F8F8F2F20000"
DATA "0000F2F2FFFFFFFFFCFCF5F5FEFEFEFEFEFEFEFEFFFFFFFFF5F5F8F8F2F20000"
DATA "0000F2F2FBFBF9F9F3F3F3F3F5F5F5F5F5F5F5F5FFFFF5F5F5F5F8F8F6F6F2F2"
DATA "0000F2F2FBFBF9F9F3F3F3F3F5F5F5F5F5F5F5F5FFFFF5F5F5F5F8F8F6F6F2F2"
DATA "F2F2F4F4FBFBF9F9F8F8F8F8F3F3F8F8F8F8F8F8FFFFF5F5F5F5FCFCF6F6F2F2"
DATA "F2F2F4F4FBFBF9F9F8F8F8F8F3F3F8F8F8F8F8F8FFFFF5F5F5F5FCFCF6F6F2F2"
DATA "F2F2F4F4F3F3F3F3F4F4F4F4F3F3F5F5F5F5F3F3F8F8FFFFFCFCF3F3F4F4F2F2"
DATA "F2F2F4F4F3F3F3F3F4F4F4F4F3F3F5F5F5F5F3F3F8F8FFFFFCFCF3F3F4F4F2F2"
DATA "F2F2F4F40000F3F3F5F5F8F8F8F8F3F3F3F3F4F4F4F4F6F6F3F30000F4F4F2F2"
DATA "F2F2F4F40000F3F3F5F5F8F8F8F8F3F3F3F3F4F4F4F4F6F6F3F30000F4F4F2F2"
DATA "0000F2F200000000F3F3F3F3F3F300000000F3F3F5F5F5F5F3F30000F2F20000"
DATA "0000F2F200000000F3F3F3F3F3F300000000F3F3F5F5F5F5F3F30000F2F20000"
END SUB
|
|
|
投稿者:しばっち
投稿日:2014年11月 6日(木)19時38分58秒
|
|
|
画面表示を変えてみました。
3マス先までを表示
PUBLIC NUMERIC XSIZE,YSIZE,XS(4),YS(4),LOC,HELP,LT,FL,XX,YY,TI,TY,MX,MY,LL
LET XSIZE=700
LET YSIZE=700
CALL GINIT(XSIZE,YSIZE)
LET M=40
LET N=40
LET HELP=3
LET LOC=2
LET XA=XSIZE/2-175
LET XB=XSIZE/2+175
LET YA=50
LET YB=400
DIM MAP(0 TO 2*M,0 TO 2*N)
FOR I=1 TO 4
READ XS(I),YS(I)
NEXT I
DATA 0,-1
DATA -1,0
DATA 0,1
DATA 1,0
CALL MAKEMAZE(MAP,M,N)
IF MAP(1,1)<>0 OR MAP(2*M-1,2*N-1)<>0 THEN STOP
LET TY=INT(TIME)
DO
LOOP WHILE TY=INT(TIME)
LET TY=INT(TIME)
LET XX=1
LET YY=1
IF MAP(1,2)=0 THEN LET R=3
IF MAP(2,1)=0 THEN LET R=4
DO
SET VIEWPORT XA/XSIZE,XB/XSIZE,(YSIZE-YB)/YSIZE,(YSIZE-YA)/YSIZE
SET WINDOW 0,XSIZE-1,YSIZE-1,0
CALL BOXFULL(0,0,XSIZE,YSIZE,0)
CALL 壁
FOR I=0 TO 3 !'MAPデータ走査,画面表示(3マス先まで)
SELECT CASE R
CASE 1
IF YY-I-1>=0 THEN LET P0=MAP(XX,YY-1-I) ELSE LET P0=7
IF XX-1>=0 AND YY-I>=0 THEN LET L0=MAP(XX-1,YY-I) ELSE LET L0=7
IF XX+1<=2*M AND YY-I>=0 THEN LET R0=MAP(XX+1,YY-I) ELSE LET R0=7
CASE 2
IF XX-I-1>=0 THEN LET P0=MAP(XX-I-1,YY) ELSE LET P0=7
IF YY+1<=2*N AND XX-I>=0 THEN LET L0=MAP(XX-I,YY+1) ELSE LET L0=7
IF YY-1>=0 AND XX-I>=0 THEN LET R0=MAP(XX-I,YY-1) ELSE LET R0=7
CASE 3
IF YY+I+1<=2*N THEN LET P0=MAP(XX,YY+I+1) ELSE LET P0=7
IF XX+1<=2*M AND YY+I<=2*N THEN LET L0=MAP(XX+1,YY+I) ELSE LET L0=7
IF XX-1>=0 AND YY+I<=2*N THEN LET R0=MAP(XX-1,YY+I) ELSE LET R0=7
CASE 4
IF XX+I+1<=2*M THEN LET P0=MAP(XX+I+1,YY) ELSE LET P0=7
IF XX+I<=2*M AND YY-1>=0 THEN LET L0=MAP(XX+I,YY-1) ELSE LET L0=7
IF XX+I<=2*M AND YY+1<=2*N THEN LET R0=MAP(XX+I,YY+1) ELSE LET R0=7
END SELECT
IF P0<>7 AND L0<>7 THEN CALL 左折路(I)
IF P0<>7 AND R0<>7 THEN CALL 右折路(I)
IF P0=7 AND L0<>7 AND R0<>7 THEN
CALL T字路(I)
EXIT FOR
ELSEIF P0=7 AND L0<>7 AND R0=7 THEN
CALL 左曲がり(I)
EXIT FOR
ELSEIF P0=7 AND R0<>7 AND L0=7 THEN
CALL 右曲がり(I)
EXIT FOR
ELSEIF P0=7 AND L0=7 AND R0=7 THEN
CALL 行き止まり(I)
EXIT FOR
END IF
NEXT I
CALL BOX(0,0,XSIZE,YSIZE,2)
SET VIEWPORT 0,1,0,1
SET WINDOW 0,XSIZE-1,YSIZE-1,0
CALL DISPLOC
IF LOC=0 AND FM=0 THEN
CALL BOXFULL(0,YSIZE-150,150,YSIZE,0)
LET FM=1
END IF
CALL DISPTIME
IF XX=2*M-1 AND YY=2*N-1 THEN !'ゴール到達
SET TEXT HEIGHT 70
SET TEXT COLOR 6
SET TEXT JUSTIFY "LEFT","TOP"
PLOT TEXT ,AT 20,50:"Congratulations"
STOP
END IF
CALL BOXFULL(0,250,160,350,0)
SET TEXT JUSTIFY "LEFT","TOP"
SET TEXT HEIGHT 20
SET TEXT COLOR 7
PLOT TEXT ,AT 0,250:"MAP 残 "&STR$(HELP)
PLOT TEXT ,AT 0,280:"位置 残 "&STR$(LOC)
LET S$=GETKEY$(XSIZE/2,YSIZE-150,100)
IF S$<>"" THEN WAIT DELAY .1
IF S$="4" THEN LET R=R+1
IF S$="6" THEN LET R=R-1
IF S$="2" THEN LET R=R+2
IF R>4 THEN LET R=R-4
IF R<1 THEN LET R=R+4
IF S$="8" AND MAP(XX+XS(R),YY+YS(R))<>7 THEN
LET XX=XX+XS(R)
LET YY=YY+YS(R)
END IF
IF S$="M" AND HELP>0 THEN !'MAP表示
CALL DISPLAYMAP(MAP,M,N,XX,YY)
LET TT=INT(TIME)
DO
LOOP WHILE TT=INT(TIME)
LET TT=INT(TIME)
DO
MOUSE POLL DMX,DMY,LEFT,RIGHT
LOOP UNTIL INT(TIME)-TT>=HELP*4 OR LEFT=1 OR RIGHT=1 !'クリックするか、時間待ち
CLEAR
LET HELP=HELP-1
END IF
IF S$="L" THEN
LET LT=INT(TIME)
LET FL=0
LET LOC=LOC-1
END IF
IF XX<0 THEN LET XX=0
IF YY<0 THEN LET YY=0
IF XX>2*M THEN LET XX=2*M
IF YY>2*N THEN LET YY=2*N
LET MAP(XX,YY)=2 !'足跡を残す(赤色)
LOOP
END
EXTERNAL SUB 壁
LET XM=XSIZE/2
LET YM=YSIZE/2
PLOT LINES:0,0;XM-20,YM-20
PLOT LINES:0,YSIZE;XM-20,YM+20
PLOT LINES:XSIZE,0;XM+20,YM-20
PLOT LINES:XSIZE,YSIZE;XM+20,YM+20
PLOT LINES:XM-20,YM-20;XM-20,YM+20
PLOT LINES:XM+20,YM-20;XM+20,YM+20
END SUB
EXTERNAL SUB 行き止まり(N)
IF N=0 THEN
CALL BOXFULL(0,0,XSIZE,YSIZE,0)
PLOT LINES:0,0;20,20
PLOT LINES:XSIZE,0;XSIZE-20,20
PLOT LINES:XSIZE,YSIZE;XSIZE-20,YSIZE-20
PLOT LINES:0,YSIZE;20,YSIZE-20
PLOT LINES:20,20;XSIZE-20,20;XSIZE-20,YSIZE-20;20,YSIZE-20;20,20
ELSE
LET L=80*N
LET SIZE=-L/8+340/8
CALL BOXFULL(L,0,XSIZE-L,YSIZE,0)
PLOT LINES:L,L;XSIZE-L,L
PLOT LINES:L,YSIZE-L;XSIZE-L,YSIZE-L
PLOT LINES:L,L;L,YSIZE-L
PLOT LINES:XSIZE-L,L;XSIZE-L,YSIZE-L
END IF
END SUB
EXTERNAL SUB T字路(N)
LET L=80*N
LET SIZE=-L/8+340/8
CALL BOXFULL(L,0,XSIZE-L,YSIZE,0)
PLOT LINES:L,L+SIZE;XSIZE-L,L+SIZE
PLOT LINES:L,YSIZE-L-SIZE;XSIZE-L,YSIZE-L-SIZE
PLOT LINES:L,L;L,YSIZE-L
PLOT LINES:XSIZE-L,L;XSIZE-L,YSIZE-L
END SUB
EXTERNAL SUB 右曲がり(N)
LET R=XSIZE-N*80
LET SIZE=R/8-260/8
CALL BOXFULL(R,0,XSIZE-R+SIZE,YSIZE,0)
PLOT LINES:R,R-SIZE;XSIZE-R+SIZE,R-SIZE
PLOT LINES:R,YSIZE-R+SIZE;XSIZE-R+SIZE,YSIZE-R+SIZE
PLOT LINES:R,R;R,YSIZE-R
PLOT LINES:XSIZE-R+SIZE,YSIZE-R+SIZE;XSIZE-R+SIZE,R-SIZE
END SUB
EXTERNAL SUB 左曲がり(N)
LET L=N*80
LET SIZE=-L/8+340/8
CALL BOXFULL(L,0,XSIZE-L-SIZE,YSIZE,0)
PLOT LINES:L,L+SIZE;XSIZE-L-SIZE,L+SIZE
PLOT LINES:L,YSIZE-L-SIZE;XSIZE-L-SIZE,YSIZE-L-SIZE
PLOT LINES:L,L;L,YSIZE-L
PLOT LINES:XSIZE-L-SIZE,YSIZE-L-SIZE;XSIZE-L-SIZE,L+SIZE
END SUB
EXTERNAL SUB 左折路(N)
LET L=N*80
LET SIZE=-L/8+340/8
CALL BOXFULL(L,0,L+SIZE,YSIZE,0)
PLOT LINES:L,L;L,YSIZE-L
PLOT LINES:L,L+SIZE;L+SIZE,L+SIZE
PLOT LINES:L,YSIZE-L-SIZE;L+SIZE,YSIZE-L-SIZE
PLOT LINES:L+SIZE,L+SIZE;L+SIZE,YSIZE-L-SIZE
END SUB
EXTERNAL SUB 右折路(N)
LET R=XSIZE-N*80
LET SIZE=R/8-260/8
CALL BOXFULL(R,0,R-SIZE,YSIZE,0)
PLOT LINES:R,R;R,YSIZE-R
PLOT LINES:R,R-SIZE;R-SIZE,R-SIZE
PLOT LINES:R,YSIZE-R+SIZE;R-SIZE,YSIZE-R+SIZE
PLOT LINES:R-SIZE,YSIZE-R+SIZE;R-SIZE,R-SIZE
END SUB
EXTERNAL SUB GINIT(XSIZE,YSIZE)
SET BITMAP SIZE XSIZE,YSIZE
SET POINT STYLE 1
SET COLOR MODE "REGULAR"
SET COLOR MIX(0) 0,0,0
SET COLOR MIX(1) 0,0,1
SET COLOR MIX(2) 1,0,0
SET COLOR MIX(3) 1,0,1
SET COLOR MIX(4) 0,1,0
SET COLOR MIX(5) 0,1,1
SET COLOR MIX(6) 1,1,0
SET COLOR MIX(7) 1,1,1
CLEAR
SET LINE COLOR 7
SET AREA COLOR 0
END SUB
EXTERNAL SUB BOXFULL(X1,Y1,X2,Y2,C)
SET AREA COLOR C
PLOT AREA:X1,Y1;X2,Y1;X2,Y2;X1,Y2;X1,Y1
END SUB
EXTERNAL SUB LINE(XS,YS,XE,YE,C)
SET COLOR C
PLOT LINES
PLOT LINES:XS,YS;XE,YE
END SUB
EXTERNAL SUB BOX(XS,YS,XE,YE,C)
CALL LINE(XS,YS,XE,YS,C)
CALL LINE(XE,YS,XE,YE,C)
CALL LINE(XE,YE,XS,YE,C)
CALL LINE(XS,YE,XS,YS,C)
END SUB
EXTERNAL SUB MAKEMAZE(MAP(,),M,N) !'迷路作成
RANDOMIZE
MAT MAP=ZER
LET S=(M-1)*(N-1)
FOR I=0 TO 2*M
LET MAP(I,0)=7
LET MAP(I,2*N)=7
NEXT I
FOR I=0 TO 2*N
LET MAP(0,I)=7
LET MAP(2*M,I)=7
NEXT I
DO
DO
LET X=INT(RND*(M+1))
LET Y=INT(RND*(N+1))
LET X0=X*2
LET Y0=Y*2
LOOP WHILE MAP(X0,Y0)=0
LET R=INT(RND*4)+1
LET XN=X0+XS(R)*2
LET YN=Y0+YS(R)*2
IF XN>0 AND XN<2*M AND YN>0 AND YN<2*N AND MAP(XN,YN)=0 THEN
IF X0=XN THEN
FOR K=Y0 TO YN STEP SGN(YN-Y0)
LET MAP(X0,K)=7
NEXT K
ELSE
FOR K=X0 TO XN STEP SGN(XN-X0)
LET MAP(K,Y0)=7
NEXT K
END IF
LET X0=XN
LET Y0=YN
LET S=S-1
END IF
LOOP WHILE S>0
END SUB
EXTERNAL SUB DISPLAYMAP(MAP(,),M,N,XX,YY)
SET VIEWPORT 0,1,0,1
SET WINDOW 0,XSIZE-1,YSIZE-1,0
CLEAR
FOR I=0 TO 2*N
FOR J=0 TO 2*M
LET C=MAP(J,I)
IF J=XX AND I=YY THEN LET C=4
IF J=2*M-1 AND I=2*N-1 THEN LET C=6
CALL BOXFULL(J*XSIZE/(2*M+1),I*YSIZE/(2*N+1),(J+1)*XSIZE/(2*M+1),(I+1)*YSIZE/(2*N+1),C)
NEXT J
NEXT I
END SUB
EXTERNAL FUNCTION AREA3(X1,Y1,X2,Y2,X3,Y3,PX,PY)
LET T=TRIANGLE(X1,Y1,X2,Y2,X3,Y3)
LET A=TRIANGLE(X1,Y1,X2,Y2,PX,PY)
LET B=TRIANGLE(X2,Y2,X3,Y3,PX,PY)
LET C=TRIANGLE(X1,Y1,X3,Y3,PX,PY)
IF A+B+C=T THEN LET AREA3=-1 ELSE LET AREA3=0
END FUNCTION
EXTERNAL FUNCTION AREA4(X1,Y1,X2,Y2,X3,Y3,X4,Y4,PX,PY)
LET A=AREA3(X1,Y1,X2,Y2,X3,Y3,PX,PY)
IF A<>0 THEN
LET AREA4=-1
EXIT FUNCTION
END IF
LET B=AREA3(X1,Y1,X4,Y4,X3,Y3,PX,PY)
IF B<>0 THEN LET AREA4=-1 ELSE LET AREA4=0
END FUNCTION
EXTERNAL FUNCTION TRIANGLE(X1,Y1,X2,Y2,X3,Y3)
LET TRIANGLE=ABS(X1*Y2+X2*Y3+X3*Y1-X2*Y1-X3*Y2-Y3*X1)/2
END FUNCTION
EXTERNAL FUNCTION GETKEY$(X,Y,SIZE)
SET AREA COLOR 4
SET TEXT COLOR 7
PLOT AREA:X,Y-SIZE;X-SIZE,Y;X,Y+SIZE;X+SIZE,Y
IF HELP>0 THEN PLOT AREA:XSIZE-150,YSIZE-150;XSIZE,YSIZE-150;XSIZE,YSIZE;XSIZE-150,YSIZE
IF LOC>0 THEN PLOT AREA:0,YSIZE-150;150,YSIZE-150;150,YSIZE;0,YSIZE
CALL LINE(X-SIZE/2,Y-SIZE/2,X+SIZE/2,Y+SIZE/2,7)
CALL LINE(X+SIZE/2,Y-SIZE/2,X-SIZE/2,Y+SIZE/2,7)
SET TEXT JUSTIFY "CENTER","HALF"
SET TEXT HEIGHT SIZE/3
LET X1=X-SIZE/2
LET Y1=Y-SIZE/2
LET X2=X1
LET Y2=Y+SIZE/2
LET X3=X+SIZE/2
LET Y3=Y2
LET X4=X3
LET Y4=Y1
PLOT TEXT ,AT X,Y-SIZE/2: "前"
PLOT TEXT ,AT X-SIZE/2,Y: "左"
PLOT TEXT ,AT X+SIZE/2,Y: "右"
PLOT TEXT ,AT X,Y+SIZE/2: "後"
IF HELP>0 THEN PLOT TEXT ,AT XSIZE-75,YSIZE-75:"MAP"
IF LOC>0 THEN
SET TEXT JUSTIFY "LEFT","HALF"
SET TEXT HEIGHT SIZE/4
PLOT TEXT ,AT 0,YSIZE-75:"現在位置"
END IF
SET AREA COLOR 2
SET TEXT JUSTIFY "CENTER","HALF"
LET GETKEY$=""
DO
MOUSE POLL X0,Y0,LEFT,RIGHT
LOOP WHILE LEFT=1 OR RIGHT=1
DO
CALL DISPTIME
CALL DISPLOC
MOUSE POLL X0,Y0,LEFT,RIGHT
LOOP UNTIL LEFT=1 OR RIGHT=1
IF AREA4(X,Y-SIZE,X1,Y1,X,Y,X4,Y4,X0,Y0)<>0 AND LEFT=1 THEN
PLOT AREA :X,Y-SIZE;X1,Y1;X,Y;X4,Y4
PLOT TEXT ,AT X,Y-SIZE/2: "前"
LET GETKEY$="8"
END IF
IF AREA4(X1,Y1,X-SIZE,Y,X2,Y2,X,Y,X0,Y0)<>0 AND LEFT=1 THEN
PLOT AREA :X1,Y1;X-SIZE,Y;X2,Y2;X,Y
PLOT TEXT ,AT X-SIZE/2,Y: "左"
LET GETKEY$="4"
END IF
IF AREA4(X,Y,X2,Y2,X,Y+SIZE,X3,Y3,X0,Y0)<>0 AND LEFT=1 THEN
PLOT AREA :X,Y;X2,Y2;X,Y+SIZE;X3,Y3
PLOT TEXT ,AT X,Y+SIZE/2: "後"
LET GETKEY$="2"
END IF
IF AREA4(X4,Y4,X,Y,X3,Y3,X+SIZE,Y,X0,Y0)<>0 AND LEFT=1 THEN
PLOT AREA :X4,Y4;X,Y;X3,Y3;X+SIZE,Y
PLOT TEXT ,AT X+SIZE/2,Y: "右"
LET GETKEY$="6"
END IF
IF HELP>0 AND AREA4(XSIZE-150,YSIZE-150,XSIZE,YSIZE-150,XSIZE,YSIZE,XSIZE-150,YSIZE,X0,Y0)<>0 AND LEFT=1 THEN
PLOT AREA :XSIZE-150,YSIZE-150;XSIZE,YSIZE-150;XSIZE,YSIZE;XSIZE-150,YSIZE
PLOT TEXT ,AT XSIZE-75,YSIZE-75:"MAP"
LET GETKEY$="M"
END IF
IF LOC>0 AND AREA4(0,YSIZE-150,150,YSIZE-150,150,YSIZE,0,YSIZE,X0,Y0)<>0 AND LEFT=1 THEN
PLOT AREA :0,YSIZE-150;150,YSIZE-150;150,YSIZE;0,YSIZE
SET TEXT JUSTIFY "LEFT","HALF"
PLOT TEXT ,AT 0,YSIZE-75:"現在位置"
LET GETKEY$="L"
END IF
END FUNCTION
EXTERNAL SUB DISPTIME
IF INT(TIME)<>TI THEN
LET TI=INT(TIME)
CALL BOXFULL(XSIZE-150,200,XSIZE,300,0)
SET TEXT COLOR 7
SET TEXT HEIGHT 20
SET TEXT JUSTIFY "LEFT","TOP"
PLOT TEXT ,AT XSIZE-150,200:"経過時間"
PLOT TEXT ,AT XSIZE-100,240:STR$(INT(TIME-TY))&"s"
END IF
END SUB
EXTERNAL SUB DISPLOC
IF INT(TIME)-LT<55 THEN LET C=7 ELSE LET C=2
IF LOC>0 AND INT(TIME)-LT<60 AND (MX<>XX OR MY<>YY OR INT(TIME)-LT<>LL) THEN
SET TEXT COLOR C
SET TEXT HEIGHT 20
SET TEXT JUSTIFY "LEFT","TOP"
CALL BOXFULL(XSIZE-150,40,XSIZE,120,0)
PLOT TEXT ,AT XSIZE-150,40:"現在位置"
PLOT TEXT ,AT XSIZE-120,80:"("&STR$(XX)&","&STR$(YY)&")"
LET MX=XX
LET MY=YY
LET LL=INT(TIME)-LT
END IF
IF INT(TIME)-LT>60 AND FL=0 THEN
CALL BOXFULL(XSIZE-150,0,XSIZE,120,0)
LET FL=1
END IF
END SUB
|
|
|
投稿者:しばっち
投稿日:2014年11月 6日(木)19時39分50秒
|
|
|
RPG風の要素を加えてみました
敵親玉(LEVEL10(3階))を倒すことが目的です。
LEVEL以外のパラメータはダミーです。
マウスではなく、キーボード入力です。
テンキーの"2","4","6","8"キーで移動。
スペースキーでMAP表示。緑の点は現在位置。更に"2","4","6","8"キーでスクロール。再度スペースキーで戻る
迷路は3階建てです
PUBLIC NUMERIC 罠,宝,階段
DIM 敵数(0 TO 10)
RANDOMIZE
CALL GINIT(700,700)
SET TEXT JUSTIFY "LEFT" , "TOP"
SET TEXT BACKGROUND "OPAQUE"
SET TEXT COLOR 7
LET M=120 !'迷路サイズ 2*M*2*N
LET N=120
LET LEVEL=1 !'初期レベル
LET 罠=-999
LET 宝=-99
LET 階段=-12345
DIM MAP(3,0 TO 2*M,0 TO 2*N)
CALL MAKEMAZE(MAP,M,N)
MAT READ 敵数
DATA 35,30,25,20,16,15,13,10,7,3,1 !'レベルごとの敵数
FOR FLOOR=1 TO 3
FOR I=1 TO 20
DO
LET X=INT(RND*2*M)+1
LET Y=INT(RND*2*N)+1
LOOP UNTIL MAP(FLOOR,X,Y)=0
LET MAP(FLOOR,X,Y)=宝 !'宝位置設定
NEXT I
FOR I=1 TO 15
DO
LET X=INT(RND*2*M)+1
LET Y=INT(RND*2*N)+1
LOOP UNTIL MAP(FLOOR,X,Y)=0
LET MAP(FLOOR,X,Y)=罠 !'罠位置設定
NEXT I
READ LS,LE
DATA 0,2 !'1F
DATA 3,6 !'2F
DATA 7,10 !'3F
FOR LEV=LS TO LE !'階層ごとに敵レベル設定
FOR I=1 TO 敵数(LEV)
DO
LET X=INT(RND*2*M)+1
LET Y=INT(RND*2*N)+1
LOOP UNTIL MAP(FLOOR,X,Y)=0
LET MAP(FLOOR,X,Y)=-10*(LEV+1)
NEXT I
NEXT LEV
NEXT FLOOR
FOR I=1 TO 10 !'階段設定 1階と2階
DO
LET X=INT(RND*2*M)+1
LET Y=INT(RND*2*N)+1
LOOP UNTIL MAP(1,X,Y)=0 AND MAP(2,X,Y)=0
LET MAP(1,X,Y)=階段
LET MAP(2,X,Y)=階段
NEXT I
FOR I=1 TO 10 !'階段設定 2階と3階
DO
LET X=INT(RND*2*M)+1
LET Y=INT(RND*2*N)+1
LOOP UNTIL MAP(2,X,Y)=0 AND MAP(3,X,Y)=0
LET MAP(2,X,Y)=階段
LET MAP(3,X,Y)=階段
NEXT I
CLEAR
LET FLOOR=1
CALL BOX(40,440,500,670,7)
DO
LET XX=INT(RND*2*M)+1 !'初期位置
LET YY=INT(RND*2*N)+1
LOOP UNTIL MAP(FLOOR,XX,YY)=0
DO !'メインループ
CALL DISPLAY(MAP,XX,YY,FLOOR,M,N)
CALL 情報表示(XX,YY,LEVEL,FLOOR)
LET S$=INKEY$(1)
IF POS("4Ll:",S$)>0 AND MAP(FLOOR,XX-1,YY)<>7 THEN LET XX=XX-1
IF POS("6Rr]",S$)>0 AND MAP(FLOOR,XX+1,YY)<>7 THEN LET XX=XX+1
IF POS("2Dd\",S$)>0 AND MAP(FLOOR,XX,YY+1)<>7 THEN LET YY=YY+1
IF POS("8Uu[",S$)>0 AND MAP(FLOOR,XX,YY-1)<>7 THEN LET YY=YY-1
IF POS("Mm "&CHR$(13),S$)>0 THEN
CALL 地図表示(MAP,FLOOR,M,N,XX,YY)
CLEAR
CALL BOX(40,440,500,670,7)
END IF
IF XX<0 THEN LET XX=0
IF YY<0 THEN LET YY=0
IF XX>2*M THEN LET XX=2*M
IF YY>2*N THEN LET YY=2*N
CALL DISPLAY(MAP,XX,YY,FLOOR,M,N)
LET C=MAP(FLOOR,XX,YY)
LET FL=0
IF C=宝 THEN
CALL 文章表示("宝を見つけた")
LET Z=RND
LET T=(LEVEL-1)/9
IF Z<.1*(2*T+1) AND LEVEL<10 THEN
CALL 文章表示("レベルが上がった")
LET LEVEL=LEVEL+1
ELSEIF Z<.4 THEN
CALL 文章表示("武器を手に入れた")
ELSEIF Z<.5 THEN
CALL 文章表示("薬を手に入れた")
ELSEIF Z<.7 THEN
LET H=INT(RND*100*LEVEL)
CALL 文章表示("体力が"&STR$(H)&"回復した")
ELSEIF Z<.9 THEN
LET H=INT(RND*100*LEVEL)
CALL 文章表示("ゴールド"&STR$(H)&"手に入れた")
END IF
LET MAP(FLOOR,XX,YY)=0
ELSEIF C=罠 THEN
CALL 文章表示("敵の罠に捕まった")
IF RND<.5 THEN
LET H=INT(RND*100)
CALL 文章表示("体力が"&STR$(H)&"減った")
END IF
LET MAP(FLOOR,XX,YY)=0
ELSEIF C=階段 AND FL=0 THEN
CALL 文章表示("階段を見つけた")
CALL 文章表示("どうしますか?")
IF FLOOR=1 THEN
CALL 文章表示("階段を上る(1) そのまま(2)")
DO
LET D$=INKEY$(1)
LOOP UNTIL D$="1" OR D$="2"
IF D$="1" THEN LET FLOOR=2
LET FL=1
ELSEIF FLOOR=3 THEN
CALL 文章表示("階段を下りる(1) そのまま(2)")
DO
LET D$=INKEY$(1)
LOOP UNTIL D$="1" OR D$="2"
IF D$="1" THEN LET FLOOR=2
LET FL=1
ELSE
IF MAP(1,XX,YY)=階段 AND MAP(2,XX,YY)=階段 THEN
CALL 文章表示("階段を下りる(1) そのまま(2)")
DO
LET D$=INKEY$(1)
LOOP UNTIL D$="1" OR D$="2"
IF D$="1" THEN LET FLOOR=1
LET FL=1
ELSE
CALL 文章表示("階段を上る(1) そのまま(2)")
DO
LET D$=INKEY$(1)
LOOP UNTIL D$="1" OR D$="2"
IF D$="1" THEN LET FLOOR=3
LET FL=1
END IF
END IF
ELSEIF C<0 AND MOD(-C,10)=0 THEN
LET LEV=-C/10-1
CALL 文章表示("LEVEL"&STR$(LEV)&"の敵が現れた。")
CALL 文章表示("どうしますか?")
CALL 文章表示("戦う(1) 逃げる(2)")
DO
LET D$=INKEY$(1)
LOOP UNTIL D$="1" OR D$="2"
IF D$="1" THEN
IF LEVEL<LEV THEN !'即死
CALL 文章表示("あなたは死にました")
CALL 文章表示("GAME OVER")
STOP
ELSEIF LEVEL>LEV THEN !'瞬殺
CALL 文章表示("敵を倒した")
LET Z=RND
LET T=(LEVEL-1)/9
IF Z<.1*(2*T+1) AND LEVEL<10 THEN
CALL 文章表示("レベルが上がった")
LET LEVEL=LEVEL+1
ELSEIF Z<.4 THEN
CALL 文章表示("武器を手に入れた")
ELSEIF Z<.8 THEN
LET H=INT(RND*100*LEVEL)
CALL 文章表示("ゴールド"&STR$(H)&"手に入れた")
END IF
ELSE
CALL 文章表示("戦闘が始まった")
DO
LET Z=RND
IF Z<.3 THEN
CALL 文章表示("敵を倒した")
IF LEV=10 THEN
CALL 文章表示("あなたは敵の親玉を倒した")
CALL 文章表示("Congratulations !!")
CALL 文章表示("GAME OVER")
STOP
END IF
LET T=(LEVEL-1)/9
IF Z<.15*(2*T+1) AND LEVEL<10 THEN
CALL 文章表示("レベルが上がった")
LET LEVEL=LEVEL+1
END IF
EXIT DO
ELSEIF Z<.5 THEN
LET H=INT(RND*100)
CALL 文章表示(STR$(H)&"のダメージを受けた")
ELSEIF Z<.8 THEN
LET H=INT(RND*100*LEVEL)
CALL 文章表示("敵に"&STR$(H)&"のダメージを与えた")
END IF
LOOP
END IF
LET MAP(FLOOR,XX,YY)=0 !'遭遇するとクリア
ELSE
IF LEV>=9 AND LEV>=LEVEL THEN
CALL 文章表示("だめだ、逃げ切れない")
CALL 文章表示("あなたは死にました")
CALL 文章表示("GAME OVER")
STOP
ELSE
LET MAP(FLOOR,XX,YY)=0
DO !'逃げるとワープ?
LET XX=INT(RND*2*M)
LET YY=INT(RND*2*N)
LOOP UNTIL MAP(FLOOR,XX,YY)=0
CALL 文章表示("逃げ切れた")
END IF
END IF
END IF
IF C<>階段 THEN LET MAP(FLOOR,XX,YY)=2 !'足跡を残す
LOOP
END
EXTERNAL SUB DISPLAY(MAP(,,),XX,YY,FLOOR,M,N)
SET TEXT HEIGHT 40
FOR I=-3 TO 3
LET X=0
FOR J=-4 TO 4
IF XX+J>=0 AND YY+I>=0 AND XX+J<=2*M AND YY+I<=2*N THEN
LET C=MAP(FLOOR,XX+J,YY+I)
IF C=階段 THEN
SET TEXT COLOR 5
PLOT TEXT ,AT X,Y:"階"
ELSEIF C=宝 THEN
SET TEXT COLOR 6
PLOT TEXT ,AT X,Y:"宝"
ELSE
IF C<0 OR C=2 THEN LET C=0
CALL BOXFULL(X,Y,X+50,Y+50,C)
END IF
ELSE
CALL BOXFULL(X,Y,X+50,Y+50,1)
END IF
LET X=X+50
NEXT J
LET Y=Y+50
NEXT I
CALL BOX(0,0,450,350,2)
CALL PUTCHARACTER(200,150,3)
END SUB
EXTERNAL SUB MAKEMAZE(MAP(,,),M,N) !'迷路作成
RANDOMIZE
DIM XS(4),YS(4)
SET TEXT HEIGHT 20
FOR I=1 TO 4
READ XS(I),YS(I)
NEXT I
DATA -1,0
DATA 1,0
DATA 0,1
DATA 0,-1
FOR FLOOR=1 TO 3
LET S=(M-1)*(N-1)
LET SS=S
CALL BOXFULL(230,230,500,260,0)
PLOT TEXT ,AT 230,230:"迷路作成中です..."&STR$(FLOOR)
CALL BOXFULL(150,270,550,300,8)
FOR I=0 TO 2*M
LET MAP(FLOOR,I,0)=7
LET MAP(FLOOR,I,2*N)=7
NEXT I
FOR I=0 TO 2*N
LET MAP(FLOOR,0,I)=7
LET MAP(FLOOR,2*M,I)=7
NEXT I
DO
DO
LET X=INT(RND*(M+1))
LET Y=INT(RND*(N+1))
LET X0=X*2
LET Y0=Y*2
LOOP WHILE MAP(FLOOR,X0,Y0)=0
LET R=INT(RND*4)+1
LET XN=X0+XS(R)*2
LET YN=Y0+YS(R)*2
IF XN>0 AND XN<2*M AND YN>0 AND YN<2*N AND MAP(FLOOR,XN,YN)=0 THEN
IF X0=XN THEN
FOR K=Y0 TO YN STEP SGN(YN-Y0)
LET MAP(FLOOR,X0,K)=7
NEXT K
ELSE
FOR K=X0 TO XN STEP SGN(XN-X0)
LET MAP(FLOOR,K,Y0)=7
NEXT K
END IF
LET X0=XN
LET Y0=YN
LET S=S-1
END IF
IF MOD(INT((SS-S)/SS*100),10)=0 THEN CALL BOXFULL(150,270,150+INT((SS-S)/SS*400),300,4)
LOOP WHILE S>0
CALL BOXFULL(150,270,550,300,4)
NEXT FLOOR
WAIT DELAY .1
END SUB
EXTERNAL SUB 地図表示(MAP(,,),FLOOR,M,N,ZX,ZY)
LET XX=ZX
IF XX-17<0 THEN LET XX=ABS(XX-17)+1
LET YY=ZY
IF YY-17<0 THEN LET YY=ABS(YY-17)+1
SET TEXT HEIGHT 15
DO
LET Y=0
CLEAR
FOR I=-17 TO 17
LET X=0
FOR J=-17 TO 17
IF XX+J>=0 AND YY+I>=0 AND XX+J<=2*M AND YY+I<=2*N THEN
LET C=MAP(FLOOR,XX+J,YY+I)
IF C=罠 THEN
SET TEXT COLOR 3
PLOT TEXT ,AT X,Y:"罠"
ELSEIF C=宝 THEN
SET TEXT COLOR 6
PLOT TEXT ,AT X,Y:"宝"
ELSEIF C=階段 THEN
SET TEXT COLOR 5
PLOT TEXT ,AT X,Y:"階"
ELSEIF MOD(-C,10)=0 THEN
LET LEV=-C/10-1
SET TEXT COLOR LEV+1
PLOT TEXT ,AT X,Y:"敵" !'LEV=0..青 LEV=1..赤 LEV=2..紫 LEV=3..緑
END IF
IF XX+J=ZX AND YY+I=ZY THEN LET C=4
IF C>=0 THEN CALL BOXFULL(X,Y,X+20,Y+20,C)
ELSE
CALL BOXFULL(X,Y,X+20,Y+20,1)
END IF
LET X=X+20
NEXT J
LET Y=Y+20
NEXT I
LET S$=INKEY$(1)
IF POS("4Ll:",S$)>0 THEN LET XX=XX-10
IF POS("6Rr]",S$)>0 THEN LET XX=XX+10
IF POS("2Dd\",S$)>0 THEN LET YY=YY+10
IF POS("8Uu[",S$)>0 THEN LET YY=YY-10
IF S$=" " OR S$=CHR$(13) THEN EXIT DO
IF XX=<0 THEN LET XX=0
IF XX>=2*M THEN LET XX=2*M
IF YY<=0 THEN LET YY=0
IF YY>=2*N THEN LET YY=2*N
LOOP
END SUB
EXTERNAL SUB GINIT(XSIZE,YSIZE)
SET BITMAP SIZE XSIZE,YSIZE
SET WINDOW 0,XSIZE-1,YSIZE-1,0
SET POINT STYLE 1
SET COLOR MODE "REGULAR"
SET COLOR MIX(0) 0,0,0
SET COLOR MIX(1) 0,0,1
SET COLOR MIX(2) 1,0,0
SET COLOR MIX(3) 1,0,1
SET COLOR MIX(4) 0,1,0
SET COLOR MIX(5) 0,1,1
SET COLOR MIX(6) 1,1,0
SET COLOR MIX(7) 1,1,1
SET COLOR MIX(9) BVAL("A4",16)/255,BVAL("91",16)/255,BVAL("76",16)/255
SET COLOR MIX(10) BVAL("E2",16)/255,BVAL("CB",16)/255,BVAL("A6",16)/255
SET COLOR MIX(11) BVAL("6F",16)/255,BVAL("55",16)/255,BVAL("31",16)/255
CLEAR
END SUB
EXTERNAL SUB BOXFULL(X1,Y1,X2,Y2,C)
SET AREA COLOR C
PLOT AREA:X1,Y1;X2,Y1;X2,Y2;X1,Y2;X1,Y1
END SUB
EXTERNAL SUB BOX(XS,YS,XE,YE,C)
CALL LINE(XS,YS,XE,YS,C)
CALL LINE(XE,YS,XE,YE,C)
CALL LINE(XE,YE,XS,YE,C)
CALL LINE(XS,YE,XS,YS,C)
END SUB
EXTERNAL SUB LINE(XS,YS,XE,YE,C)
SET COLOR C
PLOT LINES
PLOT LINES:XS,YS;XE,YE
END SUB
EXTERNAL SUB 文章表示(X$)
DIM M(460,200)
CALL BOX(40,440,500,670,0)
ASK PIXEL ARRAY (40,465) M
CALL BOXFULL(40,440,500,670,0)
MAT PLOT CELLS, IN 40,440;499,639:M
CALL BOX(40,440,500,670,7)
SET TEXT COLOR 7
SET TEXT HEIGHT 18
PLOT TEXT ,AT 40,640:X$
END SUB
EXTERNAL SUB 情報表示(XX,YY,LEVEL,FLOOR)
CALL BOXFULL(490,40,680,250,0)
CALL BOX(490,40,680,250,7)
SET TEXT COLOR 7
SET TEXT HEIGHT 20
PLOT TEXT ,AT 500,40:"LEVEL "&STR$(LEVEL)
PLOT TEXT ,AT 500,70:STR$(FLOOR)&"階"
PLOT TEXT ,AT 500,100:"座標("&STR$(XX)&","&STR$(YY)&")"
END SUB
EXTERNAL FUNCTION INKEY$(X)
SELECT CASE X
CASE 0
LET LEFTKEY$=CHR$(37)&"4Ll"
LET RIGHTKEY$=CHR$(39)&"6Rr"
LET UPKEY$=CHR$(38)&"8Uu"
LET DOWNKEY$=CHR$(40)&"2Dd"
LET CRKEY$=" "&CHR$(13)&" "&CHR$(13)
DO
FOR I=1 TO 4
LET L=GetKeyState(ORD(LEFTKEY$(I:I)))
LET U=GetKeyState(ORD(UPKEY$(I:I)))
LET R=GetKeyState(ORD(RIGHTKEY$(I:I)))
LET D=GetKeyState(ORD(DOWNKEY$(I:I)))
LET S=GetKeyState(ORD(CRKEY$(I:I)))
IF L<0 OR U<0 OR R<0 OR D<0 OR S<0 THEN EXIT DO !'キーを押すまで
NEXT I
LOOP
DO
LET FL=0
FOR I=1 TO 4
LET LL=GetKeyState(ORD(LEFTKEY$(I:I)))
LET UU=GetKeyState(ORD(UPKEY$(I:I)))
LET RR=GetKeyState(ORD(RIGHTKEY$(I:I)))
LET DD=GetKeyState(ORD(DOWNKEY$(I:I)))
LET SS=GetKeyState(ORD(CRKEY$(I:I)))
IF LL<0 OR UU<0 OR RR<0 OR DD<0 OR SS<0 THEN LET FL=1 !'キーを離すまで
NEXT I
LOOP WHILE FL=1
IF L<0 THEN LET INKEY$="4"
IF U<0 THEN LET INKEY$="8"
IF R<0 THEN LET INKEY$="6"
IF D<0 THEN LET INKEY$="2"
IF S<0 THEN LET INKEY$=" "
CASE 1
CHARACTER INPUT CLEAR:S$
LET INKEY$=S$
END SELECT
END FUNCTION
EXTERNAL SUB PUTCHARACTER(XX,YY,SIZE)
LET Y=YY
LET X=XX
FOR I=1 TO 16
READ A$
FOR J=1 TO 16
LET C=BVAL(A$(J:J),16)
CALL BOXFULL(X,Y,X+SIZE,Y+SIZE,C)
LET X=X+SIZE
NEXT J
LET X=XX
LET Y=Y+SIZE
NEXT I
DATA 0000000000000000
DATA 0000000770000000
DATA 0000000990000000
DATA 0700077777700000
DATA 0700799779970000
DATA 0700700990070000
DATA 0700999999990000
DATA 07091A0AA0A19000
DATA 070009AAAA977700
DATA 0707719009711170
DATA 6669911111716170
DATA 0AA1199669711170
DATA 0990011111177700
DATA 0000077777700000
DATA 00000BB00BB00000
DATA 00000BB00BB00000
END SUB
|
|
|
戻る