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 intY2 As Integer
Dim intX2 As Integer
Private Sub Form_Load()
intX = 200
intY = 200
intX2 = 200
intY2 = 250
With Me
.AutoRedraw = True
.KeyPreview = True
.PaintPicture imgsuit2.Picture, intX, intY
.PaintPicture imgsuit.Picture, intX2, intY2
End With
Timer1.Interval = 10
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
If GetAsyncKeyState(VK_RIGHT) <> 0 Then
intX = intX + 25
End If
If GetAsyncKeyState(VK_LEFT) <> 0 Then
intX = intX - 25
End If
If GetAsyncKeyState(VK_UP) <> 0 Then
intY = intY - 25
End If
If GetAsyncKeyState(VK_DOWN) <> 0 Then
intY = intY + 25
End If
If GetAsyncKeyState(65) <> 0 Then
intX2 = intX2 - 25
End If
If GetAsyncKeyState(83) <> 0 Then
intY2 = intY2 + 25
End If
If GetAsyncKeyState(68) <> 0 Then
intX2 = intX2 + 25
End If
If GetAsyncKeyState(87) <> 0 Then
intY2 = intY2 - 25
End If
Me.Cls
Me.PaintPicture imgsuit2.Picture, intX, intY
Me.PaintPicture imgsuit.Picture, intX2, intY2
End Sub