level 1
blueglass2
楼主
用了一上午的时间用QB写了一个DOS弹球游戏,已经调试过了,没问题。源代码如下:'弹球游戏'2键左移 6键右移 0键退出(^_^)SCREEN 12type RECTx1 as integery1 as integerfull as integerend typedim rec(10,3)dim box(10,3) as RECTdim w1,h1,bx,by,dx,dy,cont,befulldim nowxp as integer,xpos as integer, ypos as integerw1=64:h1=48:bx=320:by=445:dx=6:dy=6:nowxp=280:befull=0for i=0 to 9for j=0 to 2rec(i,j)=0box(i,j).x1=0box(i,j).y1=0box(i,j).full=0xpos=i*w1ypos=j*h1next j,idoa$=Inkey$bx=bx-dxby=by-dyif bx<=20 then dx=-dxif bx>=620 then dx=-dxif by<=20 then dy=-dyif by>=460 then call win(1)if by>=445 and bx>=nowxp+20 and bx<=nowxp+80 and by<=465 then dy=-dyfor i=1 TO 13:circle (bx,by),i,0:nextfor i=1 TO 6:circle (bx,by),i,15:nextfor i=0 to 9for j=0 to 2xpos=i*w1ypos=j*h1if rec(i,j)=0 thenline (xpos+1,ypos+1)-(xpos+w1-1,ypos+h1-1),i+2,BFend ifif box(i,j).full=1 thenbox(i,j).y1=box(i,j).y1+3:if box(i,j).y1>=480 then box(i,j).full=0line (box(i,j).x1,box(i,j).y1-4)-(box(i,j).x1+w1,box(i,j).y1+h1),black,BFline (box(i,j).x1,box(i,j).y1)-(box(i,j).x1+w1,box(i,j).y1+h1),7,BFend ifif by<=ypos+h1 and by>=ypos then if bx>=xpos+32 and bx<=xpos+64 thenif rec(i,j)=0 thendx=-dxend ifend ifend ifif bx>=xpos+12 and bx<=xpos+42 and by<=ypos+56 and by>=ypos+12 then if rec(i,j)=0 thencls dy=-dyrec(i,j)=rec(i,j)+1box(i,j).x1=xposbox(i,j).y1=yposbox(i,j).full=1cont=cont+1if cont>=27 then call win(0)end ifend ifif by<=ypos+h1 and by>=j*6 then if bx>=i*w1-6 and bx<=i*w1 thenif rec(i,j)=0 thendx=-dxend ifend ifend ifnext j,iselect case a$case "4"nowxp=nowxp-12if nowxp<=6 then nowxp=6case "6"nowxp=nowxp+12if nowxp>=560 then nowxp=560end selectcall ball(nowxp)sound 40, 1loop until a$="0"sub ball(xp as integer)line (xp-20,458)-(xp+100,480),0,BFline (xp,460)-(xp+80,480),11,BFend subsub win(idx as integer)clsfor i=1 to 5locate 15, 30color iif idx=0 thenprint "ALLRIGHT! You WIN!"elseprint "GAME OVER!"end ifsleep 1next iendend sub
2007年05月05日 04点05分
1