Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

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

Posted

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.

Posted

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

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...