主题:[原创]扑克牌21点游戏的Qbasic源代码
长达450行代码的扑克牌21点游戏的Qbasic源代码,成品于2009年3月,以函数方式写成,结构清晰自然,实乃佳品啊!以下是主要代码片段
DECLARE SUB NextRank ()
DECLARE SUB GetBet (Quit%)
DECLARE SUB StartGame (win%)
DECLARE SUB PlayerPlay (over21%)
DECLARE FUNCTION YesNo% (prompt$)
DECLARE SUB shuffle (arr() AS ANY)
DECLARE SUB Winner ()
DECLARE SUB DisplayCard (vpos%, hpos%, card AS ANY, show%)
DECLARE SUB MovePointer ()
DECLARE SUB InitDeck ()
DECLARE SUB pause ()
DECLARE FUNCTION HitOrStay% ()
DECLARE SUB DealerPlay ()
DECLARE SUB bsort (arr() AS ANY, num%)
DECLARE SUB CountHand (hand() AS ANY, num%, tot%)
DECLARE FUNCTION CardConvert% (card AS ANY)
DEFINT A-Z
COMMON SHARED NextCard, CurWorth, BetAmount, PlayerCards, DealerCards, FirstRound, DealerVal
CurWorth = 250
CONST f = 0, t = NOT f, LowBet = 10, HighBet = 100, ranks$ = "23456789TJQKA"
TYPE CardPicture
Rank AS STRING * 1
suit AS STRING * 1
END TYPE
OPTION BASE 1
DIM SHARED FullDeck(52) AS CardPicture, PlayerHand(11) AS CardPicture, DealerHand(11) AS CardPicture, Nr AS CardPicture
SCREEN 12: CLS
COLOR 1: PRINT "21"
FOR Y = 0 TO 16
yy = Y * 12 + 50
FOR x = 0 TO 16
IF POINT(x, Y) = 1 THEN
xx = x * 25 + 160
LINE (xx, yy)-STEP(10, 10), 10, BF
END IF
NEXT
NEXT