Results 1 to 7 of 7

Thread: using the keydown function in a timer

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2011
    Posts
    12

    using the keydown function in a timer

    hi, I am making a game that involves using the arrow keys I have been using the keydown function for the form but when i use it now all the timers seem to stop. this was my previous code for the arrow keys using the keydown function:
    Code:
    If e.keydata = keys.up Then
    If pbxship.Top <= 77 Then
    pbxship.Top += 10
    Else
    pbxship.Top -= 10
    End If
    ElseIf e.keydate = keys.down Then
    If pbxship.Top >= 800 Then
    PbxLazer.Top -= 10
    Else
    pbxship.Top += 10
    End If
    now i am trying to use a timer to use the arrow keys and i am using this
    Code:
    Private Declare Function GetKeyState Lib "user32" (ByVal keyCode As Integer) As Short
    
    If GetKeyState(Keys.Up) Then
    If pbxship.Top <= 77 Then
    pbxship.Top += 10
    Else
    pbxship.Top -= 10
    End If
    ElseIf GetKeyState(Keys.Down) Then
    If pbxship.Top >= 800 Then
    PbxLazer.Top -= 10
    Else
    pbxship.Top += 10
    End If
    but this does not do anything like the keys are not pressed, does anyone know how to make it work or a different way to do this in a timer

    thanks in advance
    Last edited by samqweqwe3; Feb 16th, 2012 at 08:25 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width