I have been recently working on a game using VB.net
2008 and everything is going well.
In my game the application listen for left arrow keys to move the character to the left and listen to right arrow key to move the character to the right but if i hold down the right key and then rapidly moved up my hand on left arrow and clicked on the left key the character just stop moving for about approximately 0.75 second. This lag is making the feeling of using my application really bad. What can I do?
CODE:
Private Sub eb7chimie_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
switcher(e.KeyCode)
End Sub
Private Sub switcher(ByVal keycode As String)
Select Case True
Case keycode.Equals(String.Format(Keys.Left))
'Left Arrow
leftarrow()
Case keycode.Equals(String.Format(Keys.Up))
'UpArrow
Case keycode.Equals(String.Format(Keys.Right))
'RightArrow
RightArrow()
Case keycode.Equals(String.Format(Keys.Down))
'DownArrow
Case keycode.Equals(String.Format(Keys.Escape))
'Escape
pause()
End Select
P.S.:
- This form name is eb7chimie
- the select case might look odd previuosly I was using a normal switch by i followed this advice: VB.NET How give best performance "Select case" or IF... ELSEIF ... ELSE... END IF
What I did try and do:
I searched for the problem and tried to turn on KeyPreview proprety of my form and tried to open and Application.DoEvents()
but none worked.