主题:串门来捧场,献上qbasic小游戏一个(原创)
ryowu
[专家分:6470] 发布于 2003-05-15 10:01:00
这是我以前写的一个小赛车游戏,和win比界面虽然简陋,但是在dos时代……(一言难尽啊)
没什么特别的,初学者看了可能会受一些启发
a,s,d控制移动,space退出
3 楼
ryowu [专家分:6470] 发布于 2003-05-17 23:17:00
不会吧:)b 我那天明明感觉自己贴了的呀:|难道是我那天累了...
(大家不许笑我,谁笑我我左眼看见谁:) )
DECLARE SUB delay (Seconds!)
CLS
RANDOMIZE TIMER
'==========================define=================================
TYPE carpos
carx AS INTEGER
cary AS INTEGER
END TYPE
DIM car(8) AS carpos
DIM cardy AS INTEGER
DIM mark AS LONG
DIM timec AS INTEGER
DIM level AS INTEGER
DIM player AS INTEGER
DIM x AS INTEGER
DIM dx AS INTEGER
DIM r AS INTEGER
DIM keyrecieve AS STRING
SCREEN 7
COLOR 15, 0
'==========================splash window============================
LINE (100, 50)-(220, 100), 8, B
LOCATE 9, 15
PRINT "RYOWU CAR"
DO
delay (.5)
IF i = 13 THEN
i = 0
ELSE
i = 13
END IF
LOCATE 19, 11
COLOR i, 0
PRINT "PUSH START BUTTON!"
b$ = INKEY$
IF b$ <> "" THEN EXIT DO
LOOP
COLOR 15, 0
CLS
'===========================initial para============================
replay:
'===========================game replay=============================
x = 100
cardy = 5
mark = 0
level = 1
timec = 200
player = 3
LOCATE 10, 15
PRINT "LEVEL "; level
delay (3)
CLS
'===========================level up and dead one player================
levelup:
FOR i = 0 TO 6
car(i).cary = 200
NEXT i
'==========================initial screen show========================
LINE (0, 0)-(50, 100), 3, B
LINE (0, 105)-(50, 150), 3, B
LINE (255, 0)-(305, 100), 3, B
LINE (55, 0)-(60, 250), 2, BF
LINE (245, 0)-(250, 250), 2, BF
LOCATE 2, 2
PRINT "MARK"
LOCATE 2, 34
PRINT "RYOWU"
LOCATE 4, 34
PRINT "1.24"
LOCATE 7, 34
PRINT "space"
LOCATE 8, 34
PRINT "end"
LOCATE 10, 34
PRINT "a,s,d"
LOCATE 11, 34
PRINT "ctrl"
LOCATE 6, 2
PRINT "SPEED"
LOCATE 10, 2
PRINT "LEVEL"
LOCATE 15, 2
PRINT "TIME"
DO
IF timec < 0 THEN
timec = 200
level = level + 1
cardy = cardy + 2
CLS
LOCATE 10, 15
PRINT "LEVEL "; level
delay (5)
CLS
GOTO levelup
END IF
FOR i = 0 TO 6
IF car(i).carx > x - 9 AND car(i).carx < x + 9 AND car(i).cary > 136 AND car(i).cary < 164 THEN
CLS
LOCATE 8, 15
PRINT "YOUR MARK: "; mark
LOCATE 10, 15
IF player > 1 THEN
player = player - 1
PRINT "LEFT "; player
delay (5)
CLS
GOTO levelup
ELSE
PRINT "GAME OVER!"
delay (5)
CLS
GOTO replay
END IF
END IF
IF car(i).cary > 150 + 10 * i THEN
LINE (car(i).carx, car(i).cary)-(car(i).carx + 10, car(i).cary + 15), 0, BF
car(i).carx = INT(RND * 170) + 60
car(i).cary = 0
END IF
NEXT i
FOR i = 0 TO 6
LINE (car(i).carx, car(i).cary)-(car(i).carx + 10, car(i).cary + 15), 0, BF
car(i).cary = car(i).cary + cardy
LINE (car(i).carx, car(i).cary)-(car(i).carx + 10, car(i).cary + 15), 7, BF
LINE (car(i).carx, car(i).cary)-(car(i).carx + 10, car(i).cary + 15), i + 1, B
NEXT i
delay (.1)
mark = mark + 1
timec = timec - 1
keyrecieve = INKEY$
IF keyrecieve = "a" THEN
dx = -5
END IF
IF keyrecieve = "d" THEN
dx = 5
END IF
IF keyrecieve = "s" THEN
dx = 0
END IF
IF keyrecieve = " " THEN
CLS
LOCATE 8, 15
PRINT "YOUR MARK: "; STR$(mark)
COLOR 3, 0
LOCATE 10, 10
PRINT "Thank You for playing..."
delay (3)
END
END IF
'========================show car self=========================
LINE (x, 150)-(x + 10, 165), 0, BF
IF x + dx > 62 AND x + dx < 235 THEN
x = x + dx
END IF
LINE (x, 150)-(x + 10, 165), 15, BF
LINE (x, 150)-(x + 10, 165), 7, B
'============================depand dead========================
LOCATE 4, 2
PRINT STR$(mark)
LOCATE 8, 2
PRINT cardy
LOCATE 12, 2
PRINT level
LOCATE 17, 2
PRINT timec
LOOP
' =============================== Delay ================================
' Delay based on time so that wait will be the same on any processor.
' Notice the check for negative numbers so that the delay won't
' freeze at midnight when the delay could become negative.
' ======================================================================
'
SUB delay (Seconds!) STATIC
Begin! = TIMER
DO UNTIL (TIMER - Begin! > Seconds!) OR (TIMER - Begin! < 0)
LOOP
END SUB