Xtreme
02-05-2001, 12:17 PM
I am making a game using Direct X 7 Direct Draw, and I am calling a sub that handles key press (P.S. I am not using Dx to do this it is an api). I put my game in a loop and call my key press detection sub from there. I was wondering if there was a good way to slow the detection down without being inaccurate. For instance, when in the driving game if I want to turn left and I press the left key the car might do a circle just by tapping the left key because it is so sensitive.
Thanks
klabranche
03-14-2001, 12:14 PM
create another loop in the code to slow it down
something like...
for i = 0 to 10000
doevents
next
detectKeyPress
http://www.extreme-vb.net/images/icons/smile.gif
Xtreme
03-19-2001, 10:28 AM
Thanks for the reply, i think i got it now.
Defiance
06-13-2001, 08:41 PM
You can slow it down by using X = 1 to 10000, but the proper way, I hope :), would be through this API call:
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Then, in your code where you would like to pause continuation, just write Sleep #####
change ##### to the ammount of milliseconds you want to pause it. For example, say you have a command button on a form and want to display MsgBoxes a few moments apart w/o the timer control, you could write this
Option Explicit
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Command1_Click()
MsgBox "First message"
Sleep 5000 'wait for 5 seconds before continuing
MsgBox "Next Message"
End Sub
Hope this helps
--Defiance
Soon I will answer your questions, now you will answer mine...