Люди, помогите. Решил создать игру на DirectX 7. Написал код:
| Код | Dim dx As New DirectX7 Dim di As DirectInput Dim diDEV As DirectInputDevice Dim diState As DIKEYBOARDSTATE Dim iKeyCounter As Integer
Private Sub Form_Load() Set di = dx.DirectInputCreate() If Err.Number <> 0 Then MsgBox "Error starting Direct Input, please make sure you have DirectX installed", vbApplicationModal End End If
Set diDEV = di.CreateDevice("GUID_SysKeyboard") 'Attach it to the Keyboard
diDEV.SetCommonDataFormat DIFORMAT_KEYBOARD diDEV.SetCooperativeLevel Me.hWnd, DISCL_BACKGROUND Or DISCL_NONEXCLUSIVE Me.Show
diDEV.Acquire
tmrKey.Interval = 30
tmrKey.Enabled = True End Sub
Private Sub Form_Unload(Cancel As Integer) diDEV.Unacquire End Sub
Private Sub Image1_Click()
End Sub
Private Sub tmrKey_Timer() diDEV.GetDeviceStateKeyboard diState
For iKeyCounter = 0 To 255 If diState.Key(iKeyCounter) <> 0 Then If iKeyCounter = 205 Then Image1.Left = Image1.Left + 120 End If End If Next DoEvents End Sub
|
Включаю игру и вижу, что если нажать на клавишу "Вправо" и зажать её, то картинка перемещается но мигет. Как устранить мигание? |