destress
06-22-2002, 01:27 PM
hey there,
i'm actually creating a car racing game and i need some help for the direct input codes.... my game does not seem to reconize these codes as my object does not move. Could someone please check the code.... another question is how do i assign the object to move left, right up and down
'~~~~~DIRECT INPUT~~~~~
Dim di As DirectInput
Dim diDEV As DirectInputDevice
Dim diState As DIKEYBOARDSTATE
Dim iKeyCounter As Integer
Public Sub Do_Keys()
Set di = dx.DirectInputCreate()
Set diDEV = di.CreateDevice("GUID_SysKeyboard")
diDEV.SetCommonDataFormat DIFORMAT_KEYBOARD
diDEV.SetCooperativeLevel Me.hWnd, DISCL_BACKGROUND Or DISCL_NONEXCLUSIVE
diDEV.Acquire
diDEV.GetDeviceStateKeyboard diState
If diState.Key(DIK_ESCAPE) <> 0 Then
DxEnd
End If
'Check right key press
If diState.Key(DIK_RIGHT) <> 0 Then
Car.ShiftRight
End If
'Check left key press
If diState.Key(DIK_LEFT) <> 0 Then
Car.ShiftLeft
End If
'Check Up key press
If diState.Key(DIK_UP) <> 0 Then
Car.ShiftUP
End If
'Check left key press
If diState.Key(DIK_DOWN) <> 0 Then
Car.ShiftDown
End If
End Sub
Your help is greatly appreaciated
thanks !
i'm actually creating a car racing game and i need some help for the direct input codes.... my game does not seem to reconize these codes as my object does not move. Could someone please check the code.... another question is how do i assign the object to move left, right up and down
'~~~~~DIRECT INPUT~~~~~
Dim di As DirectInput
Dim diDEV As DirectInputDevice
Dim diState As DIKEYBOARDSTATE
Dim iKeyCounter As Integer
Public Sub Do_Keys()
Set di = dx.DirectInputCreate()
Set diDEV = di.CreateDevice("GUID_SysKeyboard")
diDEV.SetCommonDataFormat DIFORMAT_KEYBOARD
diDEV.SetCooperativeLevel Me.hWnd, DISCL_BACKGROUND Or DISCL_NONEXCLUSIVE
diDEV.Acquire
diDEV.GetDeviceStateKeyboard diState
If diState.Key(DIK_ESCAPE) <> 0 Then
DxEnd
End If
'Check right key press
If diState.Key(DIK_RIGHT) <> 0 Then
Car.ShiftRight
End If
'Check left key press
If diState.Key(DIK_LEFT) <> 0 Then
Car.ShiftLeft
End If
'Check Up key press
If diState.Key(DIK_UP) <> 0 Then
Car.ShiftUP
End If
'Check left key press
If diState.Key(DIK_DOWN) <> 0 Then
Car.ShiftDown
End If
End Sub
Your help is greatly appreaciated
thanks !