主题:答对了30分
a292982250
[专家分:40] 发布于 2007-06-13 13:17:00
谁有QBASIC遍的游戏
给我的话给你30分
回复列表 (共27个回复)
沙发
pengyuhui [专家分:30] 发布于 2007-06-13 13:29:00
123456789
板凳
Matodied [专家分:7560] 发布于 2007-06-13 21:05:00
我的一个简单的游戏:[url=http://www.programfan.com/club/post-232327.html]会变色的图形[/url]
现在没时间,到了暑假我准备再编几个游戏。
3 楼
huqing [专家分:30] 发布于 2007-06-26 13:09:00
DECLARE SUB showcar (row!, col!, c!)
DECLARE SUB Win ()
DECLARE SUB MoveZ ()
DECLARE SUB MoveM (md!)
DECLARE SUB Lose ()
CONST R0 = 3, C0 = 30, S0 = 12
CONST Left = -1, Right = 1
CONST KeyUp = 72, KeyDown = 80, KeyLeft = 75, KeyRight = 77
CONST KeySpace = 57, KeyEnter = 28, KeyEsc = 1
TYPE cartype
row AS INTEGER
col AS INTEGER
END TYPE
DIM SHARED car(0 TO 3) AS cartype '存放赛车位置
DIM SHARED state(127) AS INTEGER
DIM SHARED BasePtr(0 TO 18) AS INTEGER '存放基址
DIM SHARED shape(0 TO 4, 0 TO 2) AS INTEGER
DIM SHARED mrow, mcol, count
CLS
RANDOMIZE TIMER
REM 画边框
fk$ = "[][][][][][][][][][]"
COLOR 11
LOCATE R0 - 1, C0 + 1: PRINT CHR$(201) + STRING$(20, 205) + CHR$(187)
LOCATE R0, C0 + 1: PRINT CHR$(186); SPC(20); CHR$(186)
FOR row = 1 TO 18
LOCATE R0 + row, C0 + 1: PRINT CHR$(186); SPC(20); CHR$(186)
COLOR 0: LOCATE R0 + row, C0 + 2: PRINT fk$; : COLOR 11
NEXT row
LOCATE R0 + 19, C0 + 1: PRINT CHR$(200) + STRING$(20, 205) + CHR$(188)
ptr = 160 * (R0 - 1) + 2 * (C0 - 1) + 1
FOR row = 0 TO 18
BasePtr(row) = ptr
ptr = ptr + 160
NEXT row
DEF SEG = &HB800
FOR row = 1 TO 18 STEP 4
FOR dr = 0 TO 1
ptr = BasePtr(row + dr)
POKE ptr + 4, 10
POKE ptr + 6, 10
POKE ptr + 40, 10
POKE ptr + 42, 10
NEXT dr
NEXT row
DEF SEG
REM 赛车形状
FOR i = 0 TO 4
FOR j = 0 TO 2
READ x$
shape(i, j) = VAL(x$)
NEXT j
NEXT i
4 楼
huqing [专家分:30] 发布于 2007-06-26 13:09:00
DATA 0,0,0 '赛车向下移动时 擦除最上一行
DATA 0,1,0
DATA 1,1,1
DATA 0,1,0
DATA 1,0,1
mrow = 14: mcol = 3
CALL showcar(mrow, mcol, 12)
count = 0
score = 0
delaytime = .06
DO
IF count = 0 THEN score = score + 1
LOCATE 1, 1: PRINT score
IF score = 50 THEN Win
count = count + 1
IF count = S0 THEN '两辆赛车间相隔S0行
count = 0
car(0).col = INT(2 * RND) * 3 + 3 '产生3,6
car(0).row = 0
FOR i = 3 TO 1 STEP -1
car(i).row = car(i - 1).row
car(i).col = car(i - 1).col
NEXT i
END IF
CALL MoveZ
tim = TIMER + delaytime
DO
k = INP(&H60)
IF k < 128 THEN
state(k) = 1
ELSE
state(k - 128) = 0
END IF
IF state(KeyLeft) THEN
CALL MoveM(Left)
state(KeyLeft) = 0
END IF
IF state(KeyRight) THEN
CALL MoveM(Right)
state(KeyRight) = 0
END IF
IF state(KeySpace) THEN
delaytime = .01
END IF
IF state(KeySpace) = 0 THEN
delaytime = .06
END IF
IF state(KeyEnter) THEN
DO WHILE INKEY$ = ""
LOOP
state(KeyEnter) = 0
END IF
IF state(KeyEsc) THEN
END
END IF
LOOP WHILE TIMER < tim
LOOP
END
SUB MoveM (md)
canmove = 1
IF mcol = 3 AND md = Left THEN EXIT SUB
IF mcol = 6 AND md = Right THEN EXIT SUB
FOR i = 3 TO 1
IF ABS(car(i).row - mrow) < 4 AND car(i).col <> mcol THEN
canmove = 0
EXIT FOR
END IF
NEXT i
IF canmove THEN
CALL showcar(mrow, mcol, 0)
mcol = mcol + 3 * md
CALL showcar(mrow, mcol, 12)
END IF
END SUB
SUB MoveZ
FOR i = 1 TO 3
car(i).row = count + S0 * (i - 1) '两辆赛车间相隔S0行
zrow = car(i).row: zcol = car(i).col
CALL showcar(zrow, zcol, 10)
IF ABS(car(i).row - mrow) < 4 AND car(i).col = mcol THEN Lose
NEXT i
REM 画赛道边
DEF SEG = &HB800
ptr = BasePtr(4): x = PEEK(ptr + 4)
ptr = BasePtr(0): POKE ptr + 4, x
FOR row = 18 TO 1 STEP -1
ptr = BasePtr(row - 1)
x = PEEK(ptr + 4)
ptr = BasePtr(row)
POKE ptr + 4, x
POKE ptr + 6, x
POKE ptr + 40, x
POKE ptr + 42, x
NEXT row
DEF SEG
END SUB
SUB showcar (row, col, c)
st = 0: en = 4
IF col <> 3 AND col <> 6 THEN EXIT SUB
IF row = mrow AND col = mcol THEN
st = 1
ELSE
IF row < 1 THEN st = 1 - row
IF row > 14 THEN en = 18 - row
IF st > en THEN EXIT SUB
END IF
DEF SEG = &HB800
FOR i = st TO en
ptr = BasePtr(row + i) + 4 * col
FOR j = 0 TO 2
POKE ptr + 4 * j, c * shape(i, j)
POKE ptr + 4 * j + 2, c * shape(i, j)
NEXT j
NEXT i
DEF SEG
END SUB
SUB Win
LOCATE 23, 1: PRINT "Win"
END
END SUB
SUB Lose
LOCATE 23, 1: PRINT "Lose"
END
END SUB
5 楼
把握方向 [专家分:0] 发布于 2007-07-21 17:40:00
楼上的程序有错误!!!
[fly][size=2][color=C0C0C0][color=FF0000][color=0000FF][color=FF0000][color=C0C0C0][color=FF00FF][size=4]把握方向,别误入歧途![/size][/color][/color][/color][/color][/color][/color][/size][/fly][em20]
6 楼
wzc1996 [专家分:1680] 发布于 2007-07-21 20:33:00
DECLARE SUB showcar (row!, col!, c!)
DECLARE SUB Win ()
DECLARE SUB MoveZ ()
DECLARE SUB MoveM (md!)
DECLARE SUB Lose ()
CONST R0 = 3, C0 = 30, S0 = 12
CONST Left = -1, Right = 1
CONST KeyUp = 72, KeyDown = 80, KeyLeft = 75, KeyRight = 77
CONST KeySpace = 57, KeyEnter = 28, KeyEsc = 1
TYPE cartype
row AS INTEGER
col AS INTEGER
END TYPE
DIM SHARED car(0 TO 3) AS cartype
DIM SHARED state(127) AS INTEGER
DIM SHARED BasePtr(0 TO 18) AS INTEGER
DIM SHARED shape(0 TO 4, 0 TO 2) AS INTEGER
DIM SHARED mrow, mcol, count
CLS
RANDOMIZE TIMER
REM
fk$ = "[][][][][][][][][][]"
COLOR 11
LOCATE R0 - 1, C0 + 1: PRINT CHR$(201) + STRING$(20, 205) + CHR$(187)
LOCATE R0, C0 + 1: PRINT CHR$(186); SPC(20); CHR$(186)
FOR row = 1 TO 18
LOCATE R0 + row, C0 + 1: PRINT CHR$(186); SPC(20); CHR$(186)
COLOR 0: LOCATE R0 + row, C0 + 2: PRINT fk$; : COLOR 11
NEXT row
LOCATE R0 + 19, C0 + 1: PRINT CHR$(200) + STRING$(20, 205) + CHR$(188)
ptr = 160 * (R0 - 1) + 2 * (C0 - 1) + 1
FOR row = 0 TO 18
BasePtr(row) = ptr
ptr = ptr + 160
NEXT row
DEF SEG = &HB800
FOR row = 1 TO 18 STEP 4
FOR dr = 0 TO 1
ptr = BasePtr(row + dr)
POKE ptr + 4, 10
POKE ptr + 6, 10
POKE ptr + 40, 10
POKE ptr + 42, 10
NEXT dr
NEXT row
DEF SEG
REM
FOR i = 0 TO 4
FOR j = 0 TO 2
READ x$
shape(i, j) = VAL(x$)
NEXT j
NEXT
DATA 0,0,0
DATA 0,1,0
DATA 1,1,1
DATA 0,1,0
DATA 1,0,1
mrow = 14: mcol = 3
CALL showcar(mrow, mcol, 12)
count = 0
score = 0
delaytime = .06
DO
IF count = 0 THEN score = score + 1
LOCATE 1, 1: PRINT score
IF score = 50 THEN Win
count = count + 1
IF count = S0 THEN
count = 0
car(0).col = INT(2 * RND) * 3 + 3
car(0).row = 0
FOR i = 3 TO 1 STEP -1
car(i).row = car(i - 1).row
car(i).col = car(i - 1).col
NEXT i
END IF
CALL MoveZ
tim = TIMER + delaytime
DO
k = INP(&H60)
IF k < 128 THEN
state(k) = 1
ELSE
state(k - 128) = 0
END IF
IF state(KeyLeft) THEN
CALL MoveM(Left)
state(KeyLeft) = 0
END IF
IF state(KeyRight) THEN
CALL MoveM(Right)
state(KeyRight) = 0
END IF
IF state(KeySpace) THEN
delaytime = .01
END IF
IF state(KeySpace) = 0 THEN
delaytime = .06
END IF
IF state(KeyEnter) THEN
DO WHILE INKEY$ = ""
LOOP
state(KeyEnter) = 0
END IF
IF state(KeyEsc) THEN
END
END IF
LOOP WHILE TIMER < tim
LOOP
END
SUB Lose
LOCATE 23, 1: PRINT "Lose"
END
END SUB
SUB MoveM (md)
canmove = 1
IF mcol = 3 AND md = Left THEN EXIT SUB
IF mcol = 6 AND md = Right THEN EXIT SUB
FOR i = 3 TO 1
IF ABS(car(i).row - mrow) < 4 AND car(i).col <> mcol THEN
canmove = 0
EXIT FOR
END IF
NEXT i
IF canmove THEN
CALL showcar(mrow, mcol, 0)
mcol = mcol + 3 * md
CALL showcar(mrow, mcol, 12)
END IF
END SUB
SUB MoveZ
FOR i = 1 TO 3
car(i).row = count + S0 * (i - 1)
zrow = car(i).row: zcol = car(i).col
CALL showcar(zrow, zcol, 10)
IF ABS(car(i).row - mrow) < 4 AND car(i).col = mcol THEN Lose
NEXT i
REM
DEF SEG = &HB800
ptr = BasePtr(4): x = PEEK(ptr + 4)
ptr = BasePtr(0): POKE ptr + 4, x
FOR row = 18 TO 1 STEP -1
ptr = BasePtr(row - 1)
x = PEEK(ptr + 4)
ptr = BasePtr(row)
POKE ptr + 4, x
POKE ptr + 6, x
POKE ptr + 40, x
POKE ptr + 42, x
NEXT row
DEF SEG
END SUB
SUB showcar (row, col, c)
st = 0: en = 4
IF col <> 3 AND col <> 6 THEN EXIT SUB
IF row = mrow AND col = mcol THEN
st = 1
ELSE
IF row < 1 THEN st = 1 - row
IF row > 14 THEN en = 18 - row
IF st > en THEN EXIT SUB
END IF
DEF SEG = &HB800
FOR i = st TO en
ptr = BasePtr(row + i) + 4 * col
FOR j = 0 TO 2
POKE ptr + 4 * j, c * shape(i, j)
POKE ptr + 4 * j + 2, c * shape(i, j)
NEXT j
NEXT i
DEF SEG
END SUB
SUB Win
LOCATE 23, 1: PRINT "Win"
END
END SUB
7 楼
冷石_jasv [专家分:1570] 发布于 2007-07-23 12:53:00
在..这个论坛的游戏开发栏目里我放了两个小小的..差差的QB写的游戏...一个老虎机..一个轰炸游戏....和简单的
http://www.programfan.com/club/post-219227.html
8 楼
lzh609754893 [专家分:20] 发布于 2008-11-17 21:17:00
冷石_jasv的轰炸游戏很不错
我下了一个
9 楼
ZHANGHONGCHENG [专家分:70] 发布于 2009-01-30 13:51:00
CLS
SCREEN 12: f = 3: x = 320
DO
LOCATE 1, 1: PRINT f
IF y <> 0 THEN
CIRCLE (y, z), 5: CIRCLE (w, z), 5: z = z + 5
IF z > 480 THEN y = 0: z = 0: w = 0
END IF
PSET (x, 100)
DRAW "u10r40d10l60f10r60e10l20"
PSET (x + 20, 90)
DRAW "u20f10l10"
FOR i = 1 TO 9
IF (b(i) >= w - 5 AND b(i) <= w + 5 OR b(i) >= y - 5 AND b(i) <= y + 5 AND a(i) >= z - 5) AND a(i) <= z + 5 THEN
a(i) = 500: y = 0: z = 0: u = u + 1
IF u = 2 THEN f = f + 1: u = 0
END IF
IF b(i) <= x + 60 AND b(i) >= x - 10 AND a(i) >= 108 AND a(i) <= 111 THEN
f = f - 1: IF f = 0 THEN END
END IF
IF a(i) <= 111 OR a(i) = 0 THEN a(i) = 500
IF a(i) = 500 THEN b(i) = INT(RND * 630 + 10)
PSET (b(i), a(i)), 4: DRAW "g5d20r10u20h5": PAINT (b(i), a(i) + 1), 4, 4
a(i) = a(i) - INT(RND * 6 + 1)
NEXT i
FOR i = 1 TO 100000: NEXT i
PSET (x, 100), 0
DRAW "u10r40d10l60f10r60e10l20"
PSET (x + 20, 90), 0
DRAW "u20f10l10"
LINE (1, 111)-(640, 480), 1, BF
k$ = INKEY$
IF k$ = CHR$(0) + "K" THEN x = x - 7
IF k$ = CHR$(0) + "M" THEN x = x + 7
IF k$ = CHR$(0) + "P" THEN y = x: z = 116: w = x + 50
IF k$ = CHR$(13) THEN END
IF x <= 15 THEN x = x + 7
IF x >= 580 THEN x = x - 7
LOOP
10 楼
ZHANGHONGCHENG [专家分:70] 发布于 2009-01-30 13:57:00
DECLARE SUB l4 (o!)
DECLARE SUB l3 (k$, x!, y!, f!)
DECLARE SUB l2 ()
DECLARE SUB l1 ()
CLS
SCREEN 12
RANDOMIZE TIMER
DIM SHARED a(100, 100), c(39), d(32)
DIM SHARED e(4), f(4): DIM SHARED b(4)
DATA 000000000000000011111111111000000000000
DATA 111111110000000011111111111000000000000
DATA 111111110000000011000000011000000000000
DATA 110000110000000011000000011000000000000
DATA 110000110000000011000000011000000000000
DATA 110000110000000011000000011000000000000
DATA 110000110000000011000000011000000000000
DATA 110000110000000011000000011111111111000
DATA 110000110000000011000000011111111111000
DATA 110000110011111111000000000000000011000
DATA 110000110011111111000000000000000011000
DATA 110000110011000000000000000111111111000
DATA 110000110011000000000000000111111111000
DATA 110000110011000001111111111110000000000
DATA 110000110011000001111111111110000000000
DATA 110000110011000001100000000000000000000
DATA 110000110011000001100000000000001111111
DATA 110000111111000001100000000000001111111
DATA 110000111111000001111111111111111100011
DATA 110000000000000001111111111111111100011
DATA 110000000000000000000000000000000000011
DATA 110000000000000000111111001111110000011
DATA 110000000000000000111111001111110000011
DATA 110000000000000000110011001100110000011
DATA 110000000000000000110011001100110000011
DATA 111111000000000000110011001100110011111
DATA 111111000000000000110011001100110011111
DATA 000011000000000000110011001100110011000
DATA 000011000000000000110011001100110011000
DATA 000011000000000000440011001100110011000
DATA 000011111111111111110011111100111111000
DATA 000011111111111111110011111100111111000
2 DATA 17,1,19,1,17,1,39,19,32,17,39,19,32,17,19,1
l1
END
SUB l1
FOR i = 1 TO 32: READ a$
FOR j = 1 TO 39: a(i, j) = VAL(MID$(a$, j, 1))
NEXT j, i: b(1) = 15: b(4) = 7
FOR i = 1 TO 32
FOR j = 1 TO 39
IF a(i, j) <> 0 THEN
LINE ((j - 1) * 640 / 39, (i - 1) * 460 / 32)-(j * 640 / 39, i * 460 / 32), b(a(i, j)), BF
d(i) = i * 460 / 32 - 460 / 64: c(j) = j * 640 / 39 - 640 / 78
END IF
NEXT j, i
FOR i = 1 TO 4: READ g, h, j, k
1 e(i) = INT(RND * g + h): f(i) = INT(RND * j + k)
IF a(e(i), f(i)) = 0 THEN 1
CIRCLE (c(f(i)), d(e(i))), 5, 0
NEXT i: l2
END SUB
SUB l2
x = 19: y = 30
DO: RESTORE 2
FOR i = 1 TO 4: READ g, h, j, k
WHILE a(e(i), f(i)) = 0
e(i) = INT(RND * g + h): f(i) = INT(RND * j + k)
WEND
CIRCLE (c(f(i)), d(e(i))), 5, 0
NEXT i
CIRCLE (c(x), d(y)), 5, 4
FOR i = 1 TO 500000: NEXT i: o = o + .1
CIRCLE (c(x), d(y)), 5, b(a(y, x))
k$ = INKEY$: z = x: b = y
IF (x = 19 OR x = 20) AND y = 30 THEN f = 1 ELSE f = 0
CALL l3(k$, x, y, f)
IF a(y, x) = 0 THEN x = z: y = b
IF k$ = "" THEN 10
IF (x = 19 OR x = 20) AND y = 30 AND f = 0 THEN p = p + 1
FOR i = 1 TO 4
IF x = f(i) AND y = e(i) THEN
f(i) = 0: e(i) = 0
FOR m = 1 TO 30
FOR w = 1 TO 500000: NEXT w: o = o + .1
k$ = INKEY$: k$ = ""
NEXT m
END IF
NEXT i
IF p = 1 THEN EXIT DO
10 LOOP: o = INT(o * 100 + .5) / 100
PRINT o; "MIAO"
l4 o / p
END SUB
SUB l3 (k$, x, y, f)
IF k$ = CHR$(0) + "K" THEN x = x - 1
IF k$ = CHR$(0) + "M" THEN x = x + 1
IF k$ = CHR$(0) + "H" THEN y = y - 1
IF k$ = CHR$(0) + "P" AND f = 0 THEN y = y + 1
IF k$ = CHR$(27) THEN END
END SUB
SUB l4 (o)
IF o < 45 THEN
PRINT "NI ZHEN SHI GE TIAN CAI"
ELSEIF o >= 45 AND o < 55 THEN
PRINT "NI HEN BU CUO"
ELSE
PRINT "BU XING, ZAI NU LI BA!!"
END IF
END SUB
我来回复