カラーパズル

 投稿者:しばっち  投稿日:2009年 5月10日(日)15時40分56秒
  パズルゲーム
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
 

Re: カラーパズル

 投稿者:しばっち  投稿日:2009年 5月10日(日)15時42分21秒
  > No.360[元記事へ]

マウス版 マスを左クリックする

OPTION BASE 0
RANDOMIZE
!' INPUT  PROMPT "SIZE 横,縦=":XSIZE,YSIZE
LET XSIZE=INT(RND*7)+3
LET YSIZE=INT(RND*7)+3
CALL GINIT(80*XSIZE,80*YSIZE)
SET WINDOW  0 , XSIZE , YSIZE, 0
SET TEXT JUSTIFY "LEFT" , "HALF"
FOR I=1 TO XSIZE-1
   FOR J=1 TO YSIZE-1
      CALL LINE(I,0,I,YSIZE,7)
      CALL LINE(0,J,XSIZE,J,7)
   NEXT J
NEXT I
LET KAISU=INT(RND*10)+3
!' INPUT  PROMPT "回数=":KAISU
DIM M(XSIZE,YSIZE),XX(KAISU),YY(KAISU)
DIM UNDOX(KAISU),UNDOY(KAISU)
FOR K=1 TO KAISU
   LET X=INT(RND*XSIZE)
   LET Y=INT(RND*YSIZE)
   LET XX(K)=X
   LET YY(K)=Y
   CALL MASU(X,Y,1)
NEXT  K
CALL DISPLAY
LET L=KAISU
DO
   LET FL=0
   PRINT "残り回数=";L
   DO
      MOUSE POLL X,Y,LEFT,RIGHT
   LOOP WHILE LEFT=1 OR RIGHT=1
   DO
      MOUSE POLL X,Y,LEFT,RIGHT
      IF GETKEYSTATE(27)<0 THEN LET FL=1
   LOOP WHILE LEFT=0 AND RIGHT=0 AND FL=0
   IF FL=1 THEN EXIT DO
   IF RIGHT=1 THEN
      IF KK > 0 THEN
         LET X=UNDOX(KK)
         LET Y=UNDOY(KK)
         LET KK=KK-1
         CALL MASU(X,Y,1)
         CALL DISPLAY
         LET L=L+1
      END IF
   ELSEIF LEFT=1 THEN
      LET X=INT(X)
      LET Y=INT(Y)
      PRINT "X,Y=(";X;",";Y;")"
      LET KK=KK+1
      LET UNDOX(KK)=X
      LET UNDOY(KK)=Y
      CALL MASU(X,Y,-1)
      LET L=L-1
      CALL DISPLAY
   END IF
LOOP UNTIL L=0
FOR I=0 TO XSIZE-1
   FOR J=0 TO YSIZE-1
      IF M(I,J)=0 THEN LET CHK=CHK+1
   NEXT  J
NEXT I
CLEAR
SET COLOR 7
IF CHK=XSIZE*YSIZE THEN !' ゲームクリア
   SET TEXT HEIGHT XSIZE/9.375
   PLOT TEXT ,AT 0,YSIZE/2: "Congratulations"
ELSE
   SET TEXT HEIGHT XSIZE/5.6
   PLOT TEXT ,AT 0,YSIZE/2: "Game Over"
   WAIT DELAY 1.5
   MAT M=ZER
   FOR K=1 TO KAISU
      CALL MASU(XX(K),YY(K),1)
   NEXT K
   CALL DISPLAY
   WAIT DELAY 2
   FOR K=KAISU TO 1 STEP -1 !'解答の表示
      CALL MASU(XX(K),YY(K),-1)
      PRINT "No.";KAISU-K+1;" X,Y=(";XX(K);",";YY(K);")"
      CALL DISPLAY
      WAIT DELAY 1
   NEXT K
END IF

SUB MASU(X,Y,C)
   FOR I=-1 TO 1
      FOR J=-1 TO 1
         IF X+I >= 0 AND Y+J >= 0 AND X+I < XSIZE AND Y+J < YSIZE AND I*J=0 THEN
            LET V=M(X+I,Y+J)+C
            IF V < 0 THEN LET V=7
            IF V > 7 THEN LET V=0
            LET M(X+I,Y+J)=V
         END IF
      NEXT J
   NEXT  I
END SUB

SUB DISPLAY !'画面表示
   FOR I=0 TO XSIZE-1
      FOR J=0 TO YSIZE-1
         CALL BOXFULL(I,J,I+1,J+1,M(I,J))
      NEXT  J
   NEXT I
   FOR I=1 TO XSIZE-1
      FOR J=1 TO YSIZE-1
         CALL LINE(I,0,I,YSIZE,7)
         CALL LINE(0,J,XSIZE,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
 

戻る