沙发
冷石_jasv [专家分:1570] 发布于 2004-02-01 19:16:00
DECLARE SUB box1 (xx1!, yy1!, xx2!, yy2!, col!, col1!, col2!, i!)
DECLARE SUB box (xx1!, yy1!, xx2!, yy2!, col!, col1!, col2!, i)
DECLARE SUB ink (x, y, lx, ly, rx, ry)
DIM win(16, 16)
FOR j = 1 TO 15
FOR i = 1 TO 15
READ dates
win(i, j) = dates
NEXT
NEXT
x = 15: y = 10
lx = 1: ly = 1: rx = 15: ry = 15
DIM pepple(100)
SCREEN 12
LINE (0, 0)-(20, 20), 14, BF
GET (0, 0)-(19, 19), pepple
PAINT (1, 1), 7
FOR i = lx TO rx
FOR j = ly TO ry
IF win(i, j) = 1 THEN
box1 i * 20, j * 20, i * 20 + 20, j * 20 + 20, 6, 7, 7, 1
ELSEIF win(i, j) = 9 THEN
box i * 20, j * 20, i * 20 + 20, j * 20 + 20, 14, 8, 8, 1
ELSEIF win(i, j) = 7 THEN
box i * 20, j * 20, i * 20 + 20, j * 20 + 20, 4, 8, 8, 1
ELSEIF win(i, j) = 4 THEN
'box i * 20, j * 20, i * 20 + 20, j * 20 + 20, 9, 7, 8, 1
END IF
NEXT
NEXT
FOR i = lx TO rx
FOR j = ly TO ry
IF win(i, j) = 4 THEN tempx = i: tempy = j
NEXT
NEXT
x = tempx: y = tempy
LOCATE 1, 1: PRINT win(tempx, tempy)
DO
PUT (tempx * 20, tempy * 20), pepple
ink x, y, lx, ly, rx, ry
i = x: j = y
'box i * 20, j * 20, i * 20 + 20, j * 20 + 20, 10, 8, 15, 3
PUT (i * 20, j * 20), pepple
LOOP WHILE temp$ <> CHR$(27)
END
DATA 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
DATA 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
DATA 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1
DATA 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1
DATA 1, 1, 0, 7, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1
DATA 1, 1, 0, 0, 0, 0, 0, 0, 7, 0, 0, 1, 1, 1, 1
DATA 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1
DATA 1, 1, 1, 1, 1, 1, 1, 0, 7, 1, 0, 1, 1, 1, 1
DATA 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1
DATA 1, 0, 0, 0, 4, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1
DATA 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1
DATA 1, 1, 1, 0, 7, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1
DATA 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 9, 9, 1
DATA 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 9, 9, 1
DATA 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
SUB box (xx1, yy1, xx2, yy2, col, col1, col2, i)
LINE (xx1, yy1)-(xx2, yy2), col, BF
LINE (xx1 + i, yy1 + i)-(xx2 - i, yy2 - i), col1, B
LINE (xx2 - i, yy2 - i)-(xx1 + i, yy2 - i), col2
LINE (xx2 - i, yy2 - i)-(xx2 - i, yy1 + i), col2
END SUB
SUB box1 (xx1, yy1, xx2, yy2, col, col1, col2, i)
LINE (xx1, yy1)-(xx2, yy2), col, BF
LINE (xx1, yy1)-(xx2, yy1 + (yy2 - yy1) / 2), 0, B
LINE (xx1 + (xx2 - xx1) / 2, yy1 + (yy2 - yy1) / 2)-(xx1 + (xx2 - xx1) / 2, yy1 + 2 * (yy2 - yy1) / 2), 0
LINE (xx1 + 1, yy1 + 1)-(xx2 + 1, yy1 + (yy2 - yy1) / 2 + 1), 7, B
LINE (xx1 + 1, yy1 + 1)-(xx1 + 1, yy1 + (yy2 - yy1) / 2 - 1), 7
LINE (xx1 + 1, yy1 + 1)-(xx2 + 1, yy1 + 1), 7
LINE (xx1 + (xx2 - xx1) / 2 + 1, yy1 + (yy2 - yy1) / 2 + 1)-(xx1 + (xx2 - xx1) / 2 + 1, yy1 + 2 * (yy2 - yy1) / 2 + 1), 7
END SUB
SUB ink (x, y, lx, ly, rx, ry)
SHARED temp$, win(), pepple(), tempx, tempy
tempx = x: tempy = y
xx = x: yy = y
DO
temp$ = INKEY$
LOOP WHILE temp$ = ""
tem$ = RIGHT$(temp$, 1)
SELECT CASE tem$
CASE "K"
'pRINT "<--"
IF win(xx - 1, yy) <> 1 THEN
SWAP win(xx - 1, yy), win(xx, yy)
xx = xx - 1: IF xx <= lx THEN xx = lx
ELSEIF win(xx - 1, yy) = 4 AND win(xx - 2, yy) <> 1 THEN
xx = xx - 1: IF xx <= lx THEN xx = lx
END IF
CASE "M"
'PRINT "-->"
IF win(xx + 1, yy) <> 1 THEN xx = xx + 1: IF xx >= rx THEN xx = rx
CASE "H"
'print "^"
IF win(xx, yy - 1) <> 1 THEN yy = yy - 1: IF yy <= ly THEN yy = ly
CASE "P"
'print "v"
IF win(xx, yy + 1) <> 1 THEN yy = yy + 1: IF yy >= ry THEN yy = ry
END SELECT
x = xx: y = yy
END SUB
'ink (x, y, lx, ly, rx, ry)就是编写的光标键过程