Option Explicit
Private Declare Function GetAsyncKeyState Lib _
"user32" _
(ByVal vKey As Long) As Integer
Const VK_DOWN = &H28
Const VK_LEFT = &H25
Const VK_RIGHT = &H27
Const VK_UP = &H26
Dim intX As Integer
Dim intY As Integer
Dim missile As Integer
Private Sub cmdend_Click()
End
End Sub
Private Sub Form_Load()
missile = 0
intX = 200
intY = 200
With Me
.AutoRedraw = True
.KeyPreview = True
.PaintPicture imgsuit2.Picture, intX, intY
End With
Timer1.Interval = 10
Timer1.Enabled = True
Timer2(missile).Enabled = True
Timer3.Enabled = True
End Sub
Private Sub Timer1_Timer()
If GetAsyncKeyState(VK_RIGHT) <> 0 Then
intX = intX + 100
If intX >= 6600 Then
intX = 2
End If
End If
If GetAsyncKeyState(VK_LEFT) <> 0 Then
intX = intX - 100
If intX <= 0 Then
intX = 6600
End If
End If
If GetAsyncKeyState(VK_UP) <> 0 Then
intY = intY - 100
End If
If intY <= 0 Then
intY = 6240
End If
If GetAsyncKeyState(VK_DOWN) <> 0 Then
intY = intY + 100
If intY >= 6240 Then
intY = 2
End If
End If
If missile <= 4 Then
If GetAsyncKeyState(65) <> 0 Then
Shape1(missile).Visible = True
Shape1(missile).Top = intY + 10
Shape1(missile).Left = intX + 50
Timer2(missile).Enabled = True
missile = missile + 1
End If
Else
Timer2(missile).Enabled = False
End If
Me.Cls
Me.PaintPicture imgsuit2.Picture, intX, intY
End Sub
Private Sub Timer10_Timer()
imgbot2.Left = imgbot2.Left - 100
If imgbot2.Left <= 0 Then
imgbot2.Left = 6960
Timer11.Enabled = True
imgbot.Visible = True
lblmiss.Caption = Val(lblmiss.Caption) + 1
End If
End Sub
Private Sub Timer11_Timer()
Dim flip2 As Integer
Randomize
Label3.Caption = Int(Rnd * (5 - 1) + (1))
flip2 = Int(Rnd * (5 - 1 + 1) + (1))
Label3.Caption = flip
If flip = 1 Then
imgbot2.Top = 2880
Timer11.Enabled = False
End If
If flip = 2 Then
imgbot2.Top = 500
Timer11.Enabled = False
End If
If flip = 3 Then
imgbot2.Top = 5890
Timer11.Enabled = False
End If
If flip = 4 Then
imgbot2.Top = 3462
Timer11.Enabled = False
End If
If flip = 5 Then
imgbot2.Top = 280
Timer11.Enabled = False
End If
End Sub
Private Sub Timer2_Timer(Index As Integer)
If missile <= 4 Then
Shape1(missile).Left = Shape1(missile).Left + 200
If Shape1(missile).Top + Shape1(missile).Height > imgbot.Top And Shape1(missile).Top < imgbot.Top + imgbot.Height And Shape1(missile).Left + Shape1(missile).Width > imgbot.Left And Shape1(missile).Left < imgbot.Left + imgbot.Width Then
imgbot.Left = 6960
Timer9.Enabled = True
Shape1(missile).Visible = False
Timer2(missile).Enabled = False
lblkills.Caption = Val(lblkills.Caption) + 1
End If
If Shape1(missile).Top + Shape1(missile).Height > imgbot2.Top And Shape1(missile).Top < imgbot2.Top + imgbot2.Height And Shape1(missile).Left + Shape1(missile).Width > imgbot2.Left And Shape1(missile).Left < imgbot2.Left + imgbot2.Width Then
imgbot2.Left = 6960
Timer11.Enabled = True
Shape1(missile).Visible = False
Timer2(missile).Enabled = False
lblkills.Caption = Val(lblkills.Caption) + 1
End If
End If
End Sub
Private Sub Timer3_Timer()
imgbot.Left = imgbot.Left - 100
If imgbot.Left <= 0 Then
imgbot.Left = 6960
Timer9.Enabled = True
imgbot.Visible = True
lblmiss.Caption = Val(lblmiss.Caption) + 1
End If
End Sub
Private Sub Timer4_Timer()
Line1.X1 = Line1.X1 - 500
Line1.X2 = Line1.X2 - 500
If Line1.X2 <= 0 Then
Line1.X1 = 5400
Line1.X2 = 6960
End If
End Sub
Private Sub Timer5_Timer()
Line2.X1 = Line2.X1 - 400
Line2.X2 = Line2.X2 - 400
If Line2.X1 <= 0 Then
Line2.X1 = 5640
Line2.X2 = 6600
End If
End Sub
Private Sub Timer6_Timer()
Line3.X1 = Line3.X1 - 500
Line3.X2 = Line3.X2 - 500
If Line3.X2 <= 0 Then
Line3.X1 = 4320
Line3.X2 = 5520
End If
End Sub
Private Sub Timer7_Timer()
Line4.X1 = Line4.X1 - 400
Line4.X2 = Line4.X2 - 400
If Line4.X2 <= 0 Then
Line4.X1 = 4080
Line4.X2 = 6240
End If
End Sub
Private Sub Timer8_Timer()
Line5.X1 = Line5.X1 - 500
Line5.X2 = Line5.X2 - 500
If Line5.X2 <= 0 Then
Line5.X1 = 4920
Line5.X2 = 6120
End If
End Sub
Private Sub Timer9_Timer()
Dim flip As Integer
Randomize
Label1.Caption = Int(Rnd * (5 - 1) + (1))
flip = Int(Rnd * (5 - 1 + 1) + (1))
Label1.Caption = flip
If flip = 1 Then
imgbot.Top = 2880
Timer9.Enabled = False
End If
If flip = 2 Then
imgbot.Top = 840
Timer9.Enabled = False
End If
If flip = 3 Then
imgbot.Top = 5040
Timer9.Enabled = False
End If
If flip = 4 Then
imgbot.Top = 3720
Timer9.Enabled = False
End If
If flip = 5 Then
imgbot.Top = 240
Timer9.Enabled = False
End If
End Sub