貪吃蛇PrivateSubForm_KeyDown(KeyCodeAsInteger,ShiftAsInteger)DimCAsLongIfKeyCode=27ThenEndIfKeyCode=32ThenIfTimer1.Enabled=TrueThenTimer1.Enabled=FalseLabel1.Visible=TrueElseTimer1.Enabled=TrueLabel1.Visible=FalseEndIfEndIfC=UBound(She)IfGFangXiang=TrueThenExitSubSelectCaseKeyCodeCase37IfShe(C).F=2ThenExitSubShe(C).F=0GFangXiang=TrueCase38IfShe(C).F=3ThenExitSubShe(C).F=1GFangXiang=TrueCase39IfShe(C).F=0ThenExitSubShe(C).F=2GFangXiang=TrueCase40IfShe(C).F=1ThenExitSubShe(C).F=3GFangXiang=TrueEndSelectEndSubPrivateSubForm_Load()Me.AutoRedraw=TrueMe.BackColor=&HC000&Me.FillColor=255Me.FillStyle=0Me.ScaleWidth=24Me.ScaleHeight=24Me.WindowState=2SetTimer1=Controls.Add("VB.Timer","Timer1")SetLabel1=Controls.Add("VB.Label","Label1")Label1.AutoSize=TrueLabel1.BackStyle=0Label1="暫停"Label1.ForeColor=RGB(255,255,0)Label1.FontSize=50ChuShiHuaEndSubPrivateSubForm_Resize()OnErrorGoTo1:WithMeIf.WindowState<>1Then.Cls.ScaleMode=3HWB=.ScaleHeight/.ScaleWidth.ScaleWidth=24.ScaleHeight=24Label1.Move(Me.ScaleWidth-Label1.Width)/2,(Me.ScaleHeight-Label1.Height)/2HuaTuMe.Line(X,Y)-(X+1,Y+1),RGB(255,255,0),BFEndIfEndWith3:EndSubPrivateSubTimer1_Timer()DimCAsLong,IAsLongOnErrorGoTo2:QingChuC=UBound(She)SelectCaseShe(C).FCase0IfZhuangTai(She(C).X-1,She(C).Y)=2ThenC=C+1ReDimPreserveShe(C)She(C).F=She(C-1).FShe(C).X=She(C-1).X-1She(C).Y=She(C-1).YChanShengShiWuGoTo1:ElseIfZhuangTai(She(C).X-1,She(C).Y)=1ThenGoTo2:EndIfCase1IfZhuangTai(She(C).X,She(C).Y-1)=2ThenC=C+1ReDimPreserveShe(C)She(C).F=She(C-1).FShe(C).X=She(C-1).XShe(C).Y=She(C-1).Y-1ChanShengShiWuGoTo1:ElseIfZhuangTai(She(C).X,She(C).Y-1)=1ThenGoTo2:EndIfCase2IfZhuangTai(She(C).X+1,She(C).Y)=2ThenC=C+1ReDimPreserveShe(C)She(C).F=She(C-1).FShe(C).X=She(C-1).X+1She(C).Y=She(C-1).YChanShengShiWuGoTo1:ElseIfZhuangTai(She(C).X+1,She(C).Y)=1ThenGoTo2:EndIfCase3IfZhuangTai(She(C).X,She(C).Y+1)=2ThenC=C+1ReDimPreserveShe(C)She(C).F=She(C-1).FShe(C).X=She(C-1).XShe(C).Y=She(C-1).Y+1ChanShengShiWuGoTo1:ElseIfZhuangTai(She(C).X,She(C).Y+1)=1ThenGoTo2:EndIfEndSelectZhuangTai(She(0).X,She(0).Y)=0ForI=0ToCSelectCaseShe(I).FCase0She(I).X=She(I).X-1Case1She(I).Y=She(I).Y-1Case2She(I).X=She(I).X+1Case3She(I).Y=She(I).Y+1EndSelectNextTiaoZheng1:GFangXiang=FalseZhuangTai(She(C).X,She(C).Y)=1HuaTuExitSub2:IfMsgBox("游戲結束,點“是”重新開始游戲,點“否”",vbYesNo,"貪吃蛇")=vbYesThenChuShiHuaElseEndEndIfEndSubPrivateSubChuShiHua()Me.ClsTimer1.Enabled=TrueTimer1.Interval=200EraseZhuangTaiReDimShe(2)She(0).F=2She(0).X=9She(0).Y=11ZhuangTai(9,11)=1She(1).F=2She(1).X=10She(1).Y=11ZhuangTai(10,11)=1She(2).F=2She(2).X=11She(2).Y=11ZhuangTai(11,11)=1HuaTuChanShengShiWuEndSubPrivateSubQingChu()DimIAsLongForI=0ToUBound(She)Me.Line(She(I).X,She(I).Y)-(She(I).X+1,She(I).Y+1),Me.BackColor,BFNextEndSubPrivateSubHuaTu()DimIAsLongForI=0ToUBound(She)Me.Circle(She(I).X+0.5,She(I).Y+0.5),0.49,RGB(255,255,0),,,HWBNextEndSubPrivateSubTiaoZheng()DimIAsLongForI=0ToUBound(She)-1She(I).F=She(I+1).FNextEndSubPrivateSubChanShengShiWu()RandomizeTimer1:X=Int(Rnd*24)Y=Int(Rnd*24)IfZhuangTai(X,Y)>0ThenGoTo1:ZhuangTai(X,Y)=2Me.Line(X,Y)-(X+1,Y+1),RGB(255,255,0),BFEndSub
網站導航
- zblogPHP模板zbpkf
- zblog免費模板zblogfree
- zblog模板學習zblogxuexi
- zblogPHP仿站zbpfang