|
パズルゲーム
3×3マスで構成され、配置はテンキーの数字キー(1~9)と一致する。
数字の"1"で 4,1,2
数字の"2"で 1,2,3,5
数字の"3"で 2,3,6
数字の"4"で 1,4,5,7
数字の"5"で 2,4,5,6,8
数字の"6"で 3,5,6,9,
数字の"7"で 4,7,8
数字の"8"で 5,7,8,9
数字の"9"で 6,8,9 の配置が変化する
色は、白、黄、水、緑、紫、赤、青、黒、そしてまた白の順に変化していく
画面の色全てを消したら(全て黒)クリア
OPTION BASE 0
RANDOMIZE
CALL GINIT(300,300)
SET WINDOW 0 , 3 , 3, 0
DIM X(9),Y(9),M(9),K(9,5)
FOR I=1 TO 9
READ X(I),Y(I)
NEXT I
DATA -1,1
DATA 0,1
DATA 1,1
DATA -1,0
DATA 0,0
DATA 1,0
DATA -1,-1
DATA 0,-1
DATA 1,-1
FOR I=1 TO 9
FOR J=1 TO 5
READ K(I,J)
NEXT J
NEXT I
DATA 1,2,4,0,0
DATA 1,2,3,5,0
DATA 2,3,6,0,0
DATA 1,4,7,5,0
DATA 2,4,5,6,8
DATA 3,5,6,9,0
DATA 4,7,8,0,0
DATA 5,7,8,9,0
DATA 6,8,9,0,0
!' LET KAISU=INT(RND*18)+3
INPUT PROMPT "回数=":KAISU
DIM ANS(KAISU),UNDO(KAISU)
FOR I=1 TO KAISU
LET N=INT(RND*9)+1
LET ANS(I)=N
CALL MASU(N,1)
NEXT I
CALL DISPLAY
LET L=KAISU
DO
PRINT "残り回数=";L
INPUT PROMPT "Number=":T$
IF T$="*" THEN
EXIT DO
ELSEIF T$="/" THEN
IF KK > 0 THEN
CALL MASU(UNDO(KK),1)
LET KK=KK-1
LET L=L+1
END IF
ELSEIF POS("123456789",T$) > 0 THEN
LET TE=VAL(T$)
LET KK=KK+1
LET UNDO(KK)=TE
CALL MASU(TE,-1)
LET L=L-1
END IF
CALL DISPLAY
LOOP UNTIL L=0
FOR I=1 TO 9
IF M(I)=0 THEN LET CHK=CHK+1
NEXT I
SET COLOR 7
CLEAR
IF CHK=9 THEN
SET TEXT HEIGHT 0.32
PLOT TEXT ,AT 0,1.5: "Congratulations"
ELSE
SET TEXT HEIGHT 3/5.6
PLOT TEXT ,AT 0,1.5: "Game Over"
WAIT DELAY 1.5
MAT M=ZER
FOR L=1 TO KAISU
CALL MASU(ANS(L),1)
NEXT L
CALL DISPLAY
WAIT DELAY 2
FOR L=KAISU TO 1 STEP -1
LET N=ANS(L)
PRINT "No.";KAISU-L+1;"Number=";N
CALL MASU(N,-1)
CALL DISPLAY
WAIT DELAY 1
NEXT L
END IF
SUB MASU(TE,C)
FOR J=1 TO 5
LET V=M(K(TE,J))+C
IF V < 0 THEN LET V=7
IF V > 7 THEN LET V=0
LET M(K(TE,J))=V
NEXT J
END SUB
SUB DISPLAY
FOR J=1 TO 9
CALL BOXFULL(X(J)+1,Y(J)+1,X(J)+2,Y(J)+2,M(J))
NEXT J
FOR I=1 TO 2
FOR J=1 TO 2
CALL LINE(I,0,I,3,7)
CALL LINE(0,J,3,J,7)
NEXT J
NEXT I
END SUB
END
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
END SUB
EXTERNAL SUB BOXFULL(X1,Y1,X2,Y2,C)
SET 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
|
|