Hey Im using (getkeystate) api for input and what I want to do is when some 1 presses space the Speedometer accelerates(This I can Do) but how can I make it so when space isn't pressed it will perform my deceleration. Please dont tell me to use Key_press and Key_Up.
Thanks
Visual Basic 6.0 Enterprise Edition
Java 2
Windows 98
Mac OS 9.1
Private Sub mainloop()
Do While DoEvents
If (GetKeyState(vbKeySpace)) Then
Label1 = "Up"
end if
If (GetKeyState(vbKeySpace)and key_down)
Label1 = "Down"
End If
Loop
End Sub
This was just a test but it works except for when you hold space and release.It only works if you tap space. Any idea?????
Visual Basic 6.0 Enterprise Edition
Java 2
Windows 98
Mac OS 9.1
Create a couple of Booleans for each key. when you detect that Key X has been pressed (however you want to do it), set Boolean X to TRUE. Then, in your loop, just update accordingly, then get the keystates again. When its off, then set the Boolean to FALSE. XOR might help with this, for testing if the key should be switched.
Code:
If FIGetKeyStateFunction(KeyX) Xor KeyXIsDown Then
KeyXIsDown = Not KeyXIsDown
End If
Fox I think your way is the best. But how come you need to show Me before you can call the loop. This is something that has puzzled me for years(not really).
Visual Basic 6.0 Enterprise Edition
Java 2
Windows 98
Mac OS 9.1
You have to call Me.Show, because when the main loop is in form_load, all code in the sub is executed BEFORE the form is shown. If you dont tell it to show the form first, nothing will appear to happen.