Do While tRunning
lastTick = currentTick
currentTick = Environment.TickCount
KeyIn.Poll(MessageCache, currentTick - lastTick)
Do While Not MessageCache.Count = 0
CallByName(Me, CType(MessageCache(0), gMessage).Command, CallType.Method, CType(MessageCache(0), gMessage).params)
MessageCache.RemoveAt(0)
Loop
Dim tpoint As Double() = Players(0).getPoint
txtCor.Text = Str(tpoint(0)) & Str(tpoint(1))
Application.DoEvents()
Loop
Is my main loop. The issue is with KeyIn.Poll(MessageCache, currentTick - lastTick) it runs perfectly until I press a key, and when I press the key it runs exactly the same with the exception that lasttick=currenttick for some reason. I don't know if it is relevant but the code for poll is
Public Function Poll(ByRef recv As ArrayList, ByVal ticks As Integer) As Boolean
'Return true if device is still aquired, return false if it isn't
If Active = True Then
Try
If Not KeyAc Then
kb.Acquire()
KeyAc = True
End If
Dim State As KeyboardState = kb.GetCurrentKeyboardState
'Movement
Dim movx As Single, movy As Single
Dim gm As frmGame.gMessage
Dim s As Boolean
ReDim gm.params(4)
gm.Command = "mov"
gm.params(0) = "p"
gm.params(1) = "0"
gm.params(2) = "0"
gm.params(3) = "0"
gm.params(4) = Str(ticks)
If State.Item(Key.UpArrow) Then
gm.params(3) = "1"
s = True
End If
If State.Item(Key.DownArrow) Then
gm.params(3) = Str(Int(gm.params(3)) - 1)
s = True
End If
If State.Item(Key.RightArrow) Then
gm.params(2) = "1"
s = True
End If
If State.Item(Key.LeftArrow) Then
gm.params(2) = Str(Int(gm.params(2)) - 1)
s = True
End If
If s = True Then
recv.Add(gm)
End If
Return True
Catch e As Exception
KeyAc = False
Return False
End Try
End If
End Function
If this info isn't enough, tell me and I can post the source code somewhere. HELP! (Going insane)