VB拍蚊子游戲代碼_第1頁
VB拍蚊子游戲代碼_第2頁
VB拍蚊子游戲代碼_第3頁
VB拍蚊子游戲代碼_第4頁
全文預覽已結束

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、Dim c As Integer '記錄已打死蚊子個數Dim r As IntegerDim f As Integer ' 標記蚊子飛行方向Dim s As Integer ' 倒計時秒數Dim b As IntegerSub init()'f = 1's = 60Image1.Left = -700End SubPrivate Sub Form_Load()f = 1s = 60b = 0Image1.Enabled = TrueImage2.Enabled = FalseImage2.Visible = FalseTimer2.Enabled = F

2、alseWith Image1 .Left = 0 .Top = 3000End WithWith Image2 .Left = form1.Width .Top = 3000End With Timer1.Interval = 50Timer2.Interval = 50RandomizeEnd SubPrivate Sub Image1_Click()Image1.Visible = FalseWith Image1 .Left = 0 .Top = 3000End WithWith Image2 .Left = form1.Width .Top = 3000End WithTimer1.

3、Enabled = TrueTimer2.Enabled = Falsec = c + 1Label4.Caption = cf = 1End SubPrivate Sub Image2_Click()Image2.Visible = Falsef = 1With Image1 .Left = 0 .Top = 3000 .Height = 700 .Width = 700End WithWith Image2 .Left = form1.Width .Top = 3000 .Height = 700 .Width = 700End WithTimer1.Enabled = TrueTimer

4、2.Enabled = Falsec = c + 1Label4.Caption = cEnd SubPrivate Sub Timer1_Timer() '控制向右飛If f = 2 Then Image2.Enabled = False Image2.Visible = False Image1.Enabled = True Image1.Visible = True Image1.Top = Image2.Top Image1.Left = Image2.Left Image1.Height = Image2.Height - 50 Image1.Width = Image2.W

5、idth - 50 End Iff = 1Image1.Visible = TrueIf Image1.Left < (form1.ScaleWidth - Image1.Width) Then Image1.Left = Image1.Left + 100 r = Int(Rnd * 2) + 1) Select Case r Case 1: Image1.Top = Image1.Top + 100 Case 2: Image1.Top = Image1.Top - 100 End SelectEnd If If Image1.Left >= (form1.ScaleWidth

6、 - Image1.Width) Then Timer1.Enabled = False Timer2.Enabled = TrueEnd If End SubPrivate Sub Timer2_Timer() '控制向左飛If f = 1 Then Image1.Enabled = False Image1.Visible = False Image2.Enabled = True Image2.Visible = True Image2.Top = Image1.Top Image2.Left = Image1.Left Image2.Height = Image1.Height

7、 - 50 Image2.Width = Image1.Width - 50End Iff = 2Image2.Enabled = TrueIf Image2.Left > 0 Then Image2.Left = Image2.Left - 100 r = Int(Rnd * 2) + 1) Select Case r Case 1: Image2.Top = Image1.Top + 100 Case 2: Image2.Top = Image1.Top - 100 End SelectEnd IfIf Image2.Left <= 0 Then Timer2.Enabled = False Timer1.Enabled = TrueEnd If End SubPrivate Sub Timer3_Timer() '倒計時s = s - 1Label2.Caption = sIf s < 0 Then If c >= 20 Then MsgBox "恭喜你完成任務!", 0, "結果" Timer1.Enabled = False Timer2.Enabled = False Timer3.Enabled = False Else MsgBox "對不起

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論