主題: 走迷宮遊戲
查看單個文章
舊 2018-01-08, 06:49 PM   #2 (permalink)
魔術王子
版區管理員
 
魔術王子 的頭像
榮譽勳章
UID - 115097
在線等級: 級別:42 | 在線時長:1994小時 | 升級還需:27小時級別:42 | 在線時長:1994小時 | 升級還需:27小時
註冊日期: 2004-01-13
住址: 魔術學園
文章: 2993
精華: 0
現金: 14981 金幣
資產: 2678611 金幣
預設

語法:
10 KEY OFF: CLS
20 RANDOMIZE TIMER
30 PRINT : PRINT
40 INPUT "Input Length and width (H,V)"; H, V
50 IF H <> 1 AND V <> 1 THEN 70
60 PRINT "Input Error! again...": GOTO 40
70 DIM W(H, V), V(H, V)
80 Q = 0: Z = 0: X = INT(RND * H + 1)
90 FOR i = 1 TO H
100 IF i = X THEN 120
110 PRINT ".--"; : GOTO 130
120 PRINT ".  ";
130 NEXT i
140 PRINT "."
150 C = 1: W(X, 1) = C: C = C + 1
160 R = X: S = 1: GOTO 230
170 IF R <> H THEN 210
180 IF S <> V THEN 200
190 R = 1: S = 1: GOTO 220
200 R = 1: S = S + 1: GOTO 220
210 R = R + 1
220 IF W(R, S) = 0 THEN 170
230 IF R - 1 = 0 THEN 560
240 IF W(R - 1, S) <> 0 THEN 560
250 IF S - 1 = 0 THEN 390
260 IF W(R, S - 1) <> 0 THEN 390
270 IF R = H THEN 310
280 IF W(R + 1, S) <> 0 THEN 310
290 X = INT(RND * 3 + 1)
300 ON X GOTO 900, 940, 970
310 IF S <> V THEN 340
320 IF Z = 0 THEN 370
330 Q = 1: GOTO 350
340 IF W(R, S + 1) <> 0 THEN 370
350 X = INT(RND * 3 + 1)
360 ON X GOTO 900, 940, 1040
370 X = INT(RND * 2) + 1
380 ON X GOTO 900, 940
390 IF R = H THEN 490
400 IF W(R + 1, S) <> 0 THEN 490
410 IF S <> V THEN 440
420 IF Z = 1 THEN 470
430 Q = 1: GOTO 450
440 IF W(R, S + 1) <> 0 THEN 470
450 X = INT(RND * 3 + 1)
460 ON X GOTO 900, 970, 1040
470 X = INT(RND * 2) + 1
480 ON X GOTO 900, 970
490 IF S <> V THEN 520
500 IF Z = 1 THEN 550
510 Q = 1: GOTO 530
520 IF W(R, S + 1) <> 0 THEN 550
530 X = INT(RND * 2 + 1)
540 ON X GOTO 900, 1040
550 GOTO 900
560 IF S - 1 = 0 THEN 750
570 IF W(R, S - 1) <> 0 THEN 750
580 IF R = H THEN 680
590 IF W(R + 1, S) <> 0 THEN 680
600 IF S <> V THEN 630
610 IF Z = 1 THEN 660
620 Q = 1: GOTO 640
630 IF W(R, S + 1) <> 0 THEN 660
640 X = INT(RND * 3 + 1)
650 ON X GOTO 940, 970, 1040
660 X = INT(RND * 2 + 1)
670 ON X GOTO 940, 970
680 IF S <> V THEN 710
690 IF Z = 1 THEN 740
700 Q = 1: GOTO 720
710 IF W(R, S + 1) <> 0 THEN 740
720 X = INT(RND * 2 + 1)
730 ON X GOTO 940, 1040
740 GOTO 940
750 IF R = H THEN 840
760 IF W(R + 1, S) <> 0 THEN 840
770 IF S <> V THEN 800
780 IF Z = 1 THEN 830
790 Q = 1: GOTO 950
800 IF W(R, S + 1) <> 0 THEN 830
810 X = INT(RND * 2 + 1)
820 ON X GOTO 970, 1040
830 GOTO 970
840 IF S <> V THEN 870
850 IF Z = 1 THEN 890
860 Q = 1: GOTO 880
870 IF W(R, S + 1) <> 0 THEN 890
880 GOTO 1040
890 GOTO 1140
900 W(R - 1, S) = C
910 C = C + 1: V(R - 1, S) = 2: R = R - 1
920 IF C = H * V + 1 THEN 1150
930 Q = 0: GOTO 230
940 W(R, S - 1) = C: C = C + 1
950 V(R, S - 1) = 1: S = S - 1: IF C = H * V + 1 THEN 1150
960 Q = 0: GOTO 230
970 W(R + 1, S) = C
980 C = C + 1: IF V(R, S) = 0 THEN 1000
990 V(R, S) = 3: GOTO 1010
1000 V(R, S) = 2
1010 R = R + 1
1020 IF C = H * V + 1 THEN 1150
1030 GOTO 560
1040 IF Q = 1 THEN 1100
1050 W(R, S + 1) = C: C = C + 1: IF V(R, S) = 0 THEN 1070
1060 V(R, S) = 3: GOTO 1080
1070 V(R, S) = 1
1080 S = S + 1: IF C = H * V + 1 THEN 1150
1090 GOTO 230
1100 Z = 1
1110 IF V(R, S) = 0 THEN 1130
1120 V(R, S) = 3: Q = 0: GOTO 1140
1130 V(R, S) = 1: Q = 0: R = 1: S = 1: GOTO 220
1140 GOTO 170
1150 FOR j = 1 TO V: PRINT "|";
1160 FOR i = 1 TO H
1170 IF V(i, j) < 2 THEN 1200
1180 PRINT "   ";
1190 GOTO 1210
1200 PRINT "  |";
1210 NEXT i
1220 PRINT
1230 FOR i = 1 TO H
1240 IF V(i, j) = 0 THEN 1270
1250 IF V(i, j) = 2 THEN 1270
1260 PRINT "|  "; : GOTO 1280
1270 PRINT "|--";
1280 NEXT i
1290 PRINT ".": NEXT j
1300 END
GWBASIC的程式,也是我寫Basic程式的另一個目的,就是希望能夠執行這個程式(有點遙不可及齁)
不過這程式沒辦法在VB執行,倒是可以在QB執行
前幾天有在網路找到QB64位元的程式,有編譯成執行檔,連接在下面
https://drive.google.com/file/d/1v47...ew?usp=sharing
__________________
『唸金母心咒:嗡。金母。悉地。吽。』
持此咒者,可免一切瘟疫,一切瘟神抱頭四散。

魔術就是欣賞神奇的效果
如果魔術的秘密被破解了
那魔術就失去欣賞的價值
魔術王子 目前離線  
送花文章: 1530, 收花文章: 1555 篇, 收花: 3894 次
回覆時引用此帖
有 2 位會員向 魔術王子 送花:
johnss (2018-01-13),mini (2018-01-08)
感謝您發表一篇好文章