DECLARE SUB zidan ()
DECLARE SUB mubiao ()
DECLARE SUB lose ()
DECLARE SUB win ()
DIM SHARED room(0 TO 24, 0 TO 15) AS INTEGER
DIM SHARED state(127) AS INTEGER
DIM SHARED score AS INTEGER, x0 AS INTEGER
gun = 7: x0 = 20
RANDOMIZE TIMER
VIEW PRINT 1 TO 25: CLS '初始化边界
LOCATE 1, x0 + 1: PRINT CHR$(201); STRING$(30, 205); CHR$(187)
FOR i = 2 TO 24
LOCATE i, x0 + 1: PRINT CHR$(186); SPC(30); CHR$(186)
NEXT i
DEF SEG = &HB800
POKE 24 * 160 + 2 * x0, 200
FOR j = 2 TO 60 STEP 2
POKE 24 * 160 + 2 * x0 + j, 205
NEXT j
POKE 24 * 160 + 2 * x0 + 62, 188
COLOR 9
LOCATE 24, x0 + 2 * gun: PRINT "[]"
DO
CALL mubiao '目标下移
FOR j = 1 TO 15
IF room(0, j) = 24 THEN
CALL lose
END IF
NEXT j
mubiaotime = TIMER + 1.5
DO
zidantime = TIMER + .01
DO
keyin = INP(&H60)
IF keyin < 128 THEN
state(keyin) = 1
ELSE
state(keyin - 128) = 0
END IF
LOOP UNTIL TIMER > zidantime OR INKEY$ <> ""
COLOR 9
IF state(75) THEN '按键 左
LOCATE 24, x0 + 2 * gun: PRINT " "
gun = gun - 1: IF gun = 0 THEN gun = 1
LOCATE 24, x0 + 2 * gun: PRINT "[]"
END IF
IF state(77) THEN '按键 右
LOCATE 24, x0 + 2 * gun: PRINT " "
gun = gun + 1: IF gun = 16 THEN gun = 15
LOCATE 24, x0 + 2 * gun: PRINT "[]"
END IF
IF state(57) THEN '按键 空格
room(24, 0) = gun
END IF
IF state(28) THEN '按键 回车
DO WHILE INKEY$ = ""
LOOP
END IF
IF state(1) THEN '按键 ESC
COLOR 7
END
END IF
CALL zidan
LOOP UNTIL TIMER > mubiaotime
LOOP
SUB lose
LOCATE 23, 1: PRINT "Lose"
END
END SUB
SUB mubiao
COLOR 10
FOR j = 1 TO 15 '产生目标
room(1, j) = 1: room(0, j) = room(0, j) + 1
NEXT j
FOR k = 1 TO 5
r = INT(RND * 15 + 1)
room(1, r) = 0
NEXT k
FOR i = 23 TO 2 STEP -1 '下移目标
FOR j = 1 TO 15
room(i, j) = room(i - 1, j)
IF room(i, j) = 1 THEN cc$ = "[]" ELSE cc$ = " "
LOCATE i, x0 + 2 * j: PRINT cc$
NEXT j
NEXT i
END SUB
SUB win
LOCATE 23, 1: PRINT "Win"
END
END SUB
SUB zidan
COLOR 12
FOR i = 2 TO 23
IF room(i, 0) THEN '清除显示的子弹 (预备上移)
LOCATE i, x0 + 2 * room(i, 0): PRINT " "
END IF
room(i, 0) = room(i + 1, 0)
NEXT i
FOR i = 2 TO 23
IF room(i, 0) THEN '显示子弹 (已上移)
IF room(i, room(i, 0)) = 0 THEN
LOCATE i, x0 + 2 * room(i, 0): PRINT "[]"
ELSE
LOCATE i, x0 + 2 * room(i, 0): PRINT " "
room(i, room(i, 0)) = 0
room(i, 0) = 0
score = score + 1 '击中目标分数增一
LOCATE 1, x0 + 2 * 5: PRINT "SCORE:"; score
IF score = 200 THEN win
END IF
END IF
NEXT i
room(24, 0) = 0
END SUB
正文
射击(游戏)[转贴]2005-09-20 21:17:00
【评论】 【打印】 【字体:大 中 小】 本文链接:http://blog.pfan.cn/iamben250/5051.html
阅读(1906) | 评论(0)
版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!
评论