ThePentiumGuy Posted January 23, 2005 Posted January 23, 2005 Hey, I got a quick question. When you hold down a key, windows automatically has a ersponse delay thing. For example open up notepad and hold down K, it pauses after the first K. Sort of like: K <Pause> KKKKKKKKKKKKK. How do I avoid this in my game? This gets really annoying. I want to use as little memory as possible. I tried GetASyncKey state (Win32 API) Form1_KeyDown: If getasynckeystate(keys.down) then Y + = 1 End If It still won't do it. The only alternative I found was resorting to timers: Form1_KeyDown: If e.keycode = keys.down then Timer1.Enabled = True Direction = "Down" End If Form1_KeyUp: If e.keycode = keys.down then Timer1.Enabled = False End If Timer1_Tick: If Direction = "Down" then Y += 1 End If I want to avoid using a lot of memory (ex: By using timers). Is there any way I can do this without using timers? Any quick way? -The Pentium Guy Quote My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!) vbprogramming.8k.com My Project (Need VB.NET Programmers) http://workspaces.gotdotnet.com/ResolutionRPG
Napivo1972 Posted January 24, 2005 Posted January 24, 2005 I suppose you have a loop where you do your drawing Do Move �add it here Draw Doevents Loop until end Instead of using direction use Booleans. I usually have const keyDown = vbKeydown Private bKeuDown as Boolean = False Then as you do set Boolean true and false in the keydown and keyup events. And in te move sub check the Booleans and react accordingly. Quote
ThePentiumGuy Posted January 24, 2005 Author Posted January 24, 2005 Sorry, I never got an email notifier for this post (went to junk). Heh, I did the exact same thing you were talking about before I saw this post. I just feel a little weird declaring 4 booleans.. -The Pentium Guy Quote My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!) vbprogramming.8k.com My Project (Need VB.NET Programmers) http://workspaces.gotdotnet.com/ResolutionRPG
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.