主题:[原创]赛车(游戏) 测试版
飞鸟12
[专家分:2830] 发布于 2005-08-12 10:31:00
最好是在全屏下运行,程序应该还是比较容易看懂的
DECLARE SUB Win ()
DECLARE SUB lose ()
DECLARE SUB clearcar (row!, col!)
DECLARE SUB showcar (row!, col!)
DECLARE SUB MoveZ ()
DECLARE SUB MoveM (md!)
DECLARE SUB show (row!, col!)
DECLARE SUB clr (row!, col!)
CONST Left = -1, Right = 1
CONST R0 = 3, C0 = 30
KeyUp$ = CHR$(0) + CHR$(72)
KeyDown$ = CHR$(0) + CHR$(80)
KeyLeft$ = CHR$(0) + CHR$(75)
KeyRight$ = CHR$(0) + CHR$(77)
KeySpace$ = CHR$(32)
KeyEnter$ = CHR$(13)
KeyEsc$ = CHR$(27)
DIM SHARED room(0 TO 18, 2 TO 9) AS INTEGER
DIM SHARED shape(-1 TO 3, 0 TO 2) AS INTEGER
DIM SHARED zd(0 TO 3) AS INTEGER '存放赛车位置 左边/右边
DIM SHARED mrow, mcol, zc
CLS
RANDOMIZE TIMER
REM 画边框
COLOR 11
LOCATE R0, C0 + 1: PRINT CHR$(201) + STRING$(20, 205) + CHR$(187)
FOR row = 1 TO 18
LOCATE R0 + row, C0 + 1: PRINT CHR$(186) + "[]"; SPC(16); "[]" + CHR$(186)
NEXT row
LOCATE R0 + 19, C0 + 1: PRINT CHR$(200) + STRING$(20, 205) + CHR$(188)
COLOR 10
FOR row = 1 TO 18 STEP 3
room(row, 2) = 0
CALL clr(row, 2)
CALL clr(row, 9)
FOR i = 1 TO 2
room(row + i, 2) = 1
CALL show(row + i, 2)
CALL show(row + i, 9)
NEXT i
NEXT row
REM 赛车形状
FOR i = -1 TO 3
FOR j = 0 TO 2
READ x$
shape(i, j) = VAL(x$)
NEXT j
NEXT i
DATA 0,0,0 '赛车向下移动时 擦除最上一行
DATA 0,1,0
DATA 1,1,1
DATA 0,1,0
DATA 1,0,1
mrow = 15: mcol = 3
COLOR 10
CALL showcar(mrow, mcol)
score = -1
zc = 9
DO
IF zc = 5 THEN score = score + 1
LOCATE 1, 1: PRINT score
IF score = 30 THEN Win
zc = zc + 1
IF zc = 10 THEN '两辆赛车间相隔10行
zc = 0
zd(0) = INT(2 * RND) * 2 - 1 '产生-1,1
FOR i = 3 TO 1 STEP -1
zd(i) = zd(i - 1)
NEXT i
END IF
CALL MoveZ
tim = TIMER + .06
DO
key$ = INKEY$
SELECT CASE key$
CASE KeyUp$, KeySpace$
CASE KeyDown$
CASE KeyLeft$
CALL MoveM(Left)
CASE KeyRight$
CALL MoveM(Right)
CASE KeyEnter$
DO WHILE INKEY$ = ""
LOOP
CASE KeyEsc$
END
END SELECT
LOOP WHILE TIMER < tim
LOOP
END
回复列表 (共10个回复)
沙发
飞鸟12 [专家分:2830] 发布于 2005-08-03 11:54:00
SUB MoveM (md)
COLOR 12
canmove = 1
IF mcol = 3 AND md = Left THEN EXIT SUB
IF mcol = 6 AND md = Right THEN EXIT SUB
FOR i = 0 TO 3
IF room(mrow + i, mcol + 3 * md) = 1 THEN
canmove = 0
EXIT FOR
END IF
NEXT i
IF canmove THEN
CALL clearcar(mrow, mcol)
mcol = mcol + 3 * md
CALL showcar(mrow, mcol)
END IF
END SUB
SUB MoveZ
COLOR 10
FOR i = 1 TO 3
zrow = zc + 10 * i - 13 '两辆赛车间相隔10行
IF zd(i) = Left THEN
CALL showcar(zrow + 1, 3)
ELSEIF zd(i) = Right THEN
CALL showcar(zrow + 1, 6)
END IF
NEXT i
IF room(mrow, mcol) = 1 THEN lose '撞车
REM 画赛道边
room(0, 2) = room(3, 2)
FOR row = 18 TO 1 STEP -1
room(row, 2) = room(row - 1, 2)
IF room(row, 2) = 1 THEN
CALL show(row, 2)
CALL show(row, 9)
ELSE
CALL clr(row, 2)
CALL clr(row, 9)
END IF
NEXT row
COLOR 12
CALL showcar(mrow, mcol)
END SUB
SUB show (row, col)
IF row < 1 OR row > 18 THEN EXIT SUB
IF col < 1 OR col > 10 THEN EXIT SUB
room(row, col) = 1
LOCATE R0 + row, C0 + col * 2: PRINT "[]"
END SUB
SUB clr (row, col)
IF row < 1 OR row > 18 THEN EXIT SUB
IF col < 1 OR col > 10 THEN EXIT SUB
room(row, col) = 0
LOCATE R0 + row, C0 + col * 2: PRINT " "
END SUB
SUB showcar (row, col)
start = -1
IF row = mrow AND col = mcol THEN start = 0
FOR i = start TO 3 '赛车向下移动时 擦除是否最上一行
FOR j = 0 TO 2
IF shape(i, j) = 1 THEN
CALL show(row + i, col + j)
ELSE
CALL clr(row + i, col + j)
END IF
NEXT j
NEXT i
END SUB
SUB clearcar (row, col)
FOR i = 0 TO 3
FOR j = 0 TO 2
CALL clr(row + i, col + j)
NEXT j
NEXT i
END SUB
SUB Win
LOCATE 23, 1: PRINT "Win"
END
END SUB
SUB lose
LOCATE 23, 1: PRINT "Lose"
END
END SUB
板凳
moz [专家分:37620] 发布于 2005-08-03 13:39:00
果然高手
3 楼
davidw017 [专家分:4170] 发布于 2005-08-03 13:56:00
传说中的绝世高手……
4 楼
zqnhlm [专家分:780] 发布于 2005-08-03 16:11:00
赛车之间紧了一点
5 楼
莫非白 [专家分:750] 发布于 2005-08-04 09:26:00
要知道,他是在网吧里写出来的,我在网 吧里见过他,果然是~~~~~强!!![em12][em11][em14][em2]
6 楼
zqnhlm [专家分:780] 发布于 2005-08-09 09:18:00
程序出错啊!!!!!!
7 楼
莫非白 [专家分:750] 发布于 2005-08-09 13:53:00
运行不过去啊
8 楼
飞鸟12 [专家分:2830] 发布于 2005-08-10 13:42:00
to 9楼的lushoufa:
好了 可以运行了
欢迎提出修改意见
我会在“赛车(游戏)的 初级版”中,使游戏更加完善。
9 楼
lushoufa [专家分:140] 发布于 2005-08-11 08:17:00
还的不能运行[em15][em15][em15]
10 楼
popoa [专家分:100] 发布于 2005-08-12 19:37:00
快一点儿出来
我来回复