《VB坦克大戰(zhàn)代碼》由會(huì)員分享,可在線閱讀,更多相關(guān)《VB坦克大戰(zhàn)代碼(5頁(yè)珍藏版)》請(qǐng)?jiān)谘b配圖網(wǎng)上搜索。
1、Private Sub Form_Load()
La.Top = 4000
La.Left = 3000
La.Height = 800
La.Width = 900
Lb.Top = 4300
Lb.Left = 3900
Lb.Height = 200
Lb.Width = 900
Lc.Top = 4300
Lc.Left = 4560
Lc.Height = 200
Lc.Width = 200
End Sub
Private Sub Form_keypress(keyasci
2、i As Integer)
If keyascii = 106 Then
La.Enabled = False
Lb.Enabled = False
If La.Top - Lb.Top = 900 And Lb.Left - La.Left = 300 Then
Lc.Top = La.Top - 900
Lc.Left = La.Left + 300
Lc.Visible = True
Timer1.Enabled = True
Timer2.Enabled = False
Timer3.Enabled = False
Ti
3、mer4.Enabled = False
ElseIf La.Left - Lb.Left = 900 And Lb.Top - La.Top = 300 Then
Lc.Top = La.Top + 300
Lc.Left = La.Left - 900
Lc.Visible = True
Timer1.Enabled = False
Timer2.Enabled = True
Timer3.Enabled = False
Timer4.Enabled = False
ElseIf Lb.Top - La.Top = 900 And L
4、b.Left - La.Left = 300 Then
Lc.Top = La.Top + 1600
Lc.Left = La.Left + 300
Lc.Visible = True
Timer1.Enabled = False
Timer2.Enabled = False
Timer3.Enabled = True
Timer4.Enabled = False
ElseIf Lb.Left - La.Left = 900 And Lb.Top - La.Top = 300 Then
Lc.Top = La.Top + 300
Lc
5、.Left = La.Left + 1600
Lc.Visible = True
Timer1.Enabled = False
Timer2.Enabled = False
Timer3.Enabled = False
Timer4.Enabled = True
End If
ElseIf keyascii = 119 Then
La.Enabled = True
Lb.Enabled = True
Lb.Left = La.Left + 300
Lb.Top = La.Top - 900
La.Height =
6、900
La.Width = 800
Lb.Width = 200
Lb.Height = 900
If Lb.Top <= 0 Then
Lb.Enabled = False
La.Enabled = False
Else
La.Top = La.Top - 100
Lb.Top = Lb.Top - 100
End If
ElseIf keyascii = 97 Then
La.Enabled = True
Lb.Enabled
7、= True
Lb.Left = La.Left - 900
Lb.Top = La.Top + 300
La.Height = 800
La.Width = 900
Lb.Width = 900
Lb.Height = 200
If Lb.Left <= 0 Then
Lb.Enabled = False
La.Enabled = False
Else
La.Left = La.Left - 100
Lb.Left = Lb.Left - 100
8、
End If
ElseIf keyascii = 100 Then
La.Enabled = True
Lb.Enabled = True
Lb.Left = La.Left + 900
Lb.Top = La.Top + 300
La.Height = 800
La.Width = 900
Lb.Width = 900
Lb.Height = 200
If Lb.Left >= 8700 Then
Lb.Enabled = False
La.Enabled =
9、 False
Else
La.Left = La.Left + 100
Lb.Left = Lb.Left + 100
End If
ElseIf keyascii = 115 Then
La.Enabled = True
Lb.Enabled = True
Lb.Left = La.Left + 300
Lb.Top = La.Top + 900
La.Height = 900
La.Width = 800
Lb.Width = 200
Lb.Height
10、 = 900
If Lb.Top >= 7600 Then
Lb.Enabled = False
La.Enabled = False
Else
La.Top = La.Top + 100
Lb.Top = Lb.Top + 100
End If
ElseIf keyascii = 8 Then
End
End If
End Sub
Private Sub Timer1_Timer()
Do While Lc.Top > 0
Lc.Top = Lc.To
11、p - 2
Lc.Left = Lc.Left
If Lc.Left > Ld.Left And Lc.Left < Ld.Left + Ld.Width And Lc.Top > Ld.Top And Lc.Top < Ld.Top + Ld.Height Then
Ld.Visible = False
Lc.Visible = False
End If
Loop
Lc.Visible = False
Timer1.Enabled = False
End Sub
Private Su
12、b Timer2_Timer()
Do While Lc.Left > 0
Lc.Left = Lc.Left - 2
Lc.Top = Lc.Top
If Lc.Left > Ld.Left And Lc.Left < Ld.Left + Ld.Width And Lc.Top > Ld.Top And Lc.Top < Ld.Top + Ld.Height Then
Ld.Visible = False
Lc.Visible = False
End If
13、 Loop
Lc.Visible = False
Timer2.Enabled = False
End Sub
Private Sub Timer3_Timer()
Do While Lc.Top < 8880
Lc.Top = Lc.Top + 2
Lc.Left = Lc.Left
If Lc.Left > Ld.Left And Lc.Left < Ld.Left + Ld.Width And Lc.Top > Ld.Top And Lc.Top < Ld.Top + Ld.Height Then
Ld.V
14、isible = False
Lc.Visible = False
End If
Loop
Lc.Visible = False
Timer3.Enabled = False
End Sub
Private Sub Timer4_Timer()
Do While Lc.Left < 9750
Lc.Left = Lc.Left + 2
Lc.Top = Lc.Top
If Lc.Left > Ld.Left And Lc.Left < Ld.Left + Ld.Width And Lc.Top > Ld.Top And Lc.Top < Ld.Top + Ld.Height Then
Ld.Visible = False
Lc.Visible = False
End If
Loop
Lc.Visible = False
Timer4.Enabled = False
End Sub