react faster

Discussion in 'Programming General' started by kharg0, Mar 25, 2007.

react faster
  1. Unread #1 - Mar 25, 2007 at 1:31 PM
  2. kharg0
    Joined:
    Feb 25, 2007
    Posts:
    131
    Referrals:
    0
    Sythe Gold:
    0

    kharg0 Active Member

    react faster

    how can i make this code react faster???

    Code:
    Dim Hi As Integer
    Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress
    If e.KeyChar = Chr(Asc("w")) Then
    Button1.Location = New Point(Button1.Location.X, Button1.Location.Y - 4)
    ElseIf e.KeyChar = Chr(Asc("d")) Then
    Button1.Location = New Point(Button1.Location.X + 4, Button1.Location.Y)
    ElseIf e.KeyChar = Chr(Asc("a")) Then
    Button1.Location = New Point(Button1.Location.X - 4, Button1.Location.Y)
    ElseIf e.KeyChar = Chr(Asc("s")) Then
    Button1.Location = New Point(Button1.Location.X, Button1.Location.Y + 4)
    ElseIf e.KeyChar = Chr(Asc("q")) Then
    Hi = Hi + 1
    PictureBox1.Image = Image.FromFile("C:\Documents and Settings\Jaco\My Documents\My Pictures\Move 2.bmp")
    If Hi = 2 Then
    PictureBox1.Image = Image.FromFile("C:\Documents and Settings\Jaco\My Documents\My Pictures\Move 1.bmp")
    Hi = 0
    End If
    End If
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    PictureBox1.Image = Image.FromFile("C:\Documents and Settings\Jaco\My Documents\My Pictures\Move 1.bmp")
    End Sub

    i want it to move the thing faster like the second you press watever it will go down so far this just takes a second to react thx Code Credits go to skeletron
     
  3. Unread #2 - Mar 25, 2007 at 7:09 PM
  4. Flaming Idiots
    Joined:
    Dec 22, 2005
    Posts:
    235
    Referrals:
    1
    Sythe Gold:
    0
    Two Factor Authentication User

    Flaming Idiots Active Member
    Visual Basic Programmers

    react faster

    Try this:
    Code:
        Dim Hi As Integer = 0
    
        Dim Move1 As New Bitmap("C:\Documents and Settings\Jaco\My Documents\My Pictures\Move 2.bmp")
        Dim Move2 As New Bitmap("C:\Documents and Settings\Jaco\My Documents\My Pictures\Move 1.bmp")
    
        Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress
            If e.KeyChar = Chr(Asc("w")) Then
                Button1.Location = New Point(Button1.Location.X, Button1.Location.Y - 4)
            ElseIf e.KeyChar = Chr(Asc("d")) Then
                Button1.Location = New Point(Button1.Location.X + 4, Button1.Location.Y)
            ElseIf e.KeyChar = Chr(Asc("a")) Then
                Button1.Location = New Point(Button1.Location.X - 4, Button1.Location.Y)
            ElseIf e.KeyChar = Chr(Asc("s")) Then
                Button1.Location = New Point(Button1.Location.X, Button1.Location.Y + 4)
            ElseIf e.KeyChar = Chr(Asc("q")) Then
                Hi += 1
                If Hi = 1 Then
                    PictureBox1.Image = Move2
                Else
                    PictureBox1.Image = Move1
                    Hi = 0
                End If
            End If
        End Sub
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            PictureBox1.Image = Move1
        End Sub
    The difference is that it loads the pictures when the programs start, not every time you press a button.
     
  5. Unread #3 - Mar 25, 2007 at 7:33 PM
  6. kharg0
    Joined:
    Feb 25, 2007
    Posts:
    131
    Referrals:
    0
    Sythe Gold:
    0

    kharg0 Active Member

    react faster

    alright thx flaming idiots
     
  7. Unread #4 - Mar 29, 2007 at 6:59 PM
  8. DisturbedOne
    Joined:
    Jan 21, 2007
    Posts:
    54
    Referrals:
    0
    Sythe Gold:
    0

    DisturbedOne Member

    react faster

    You insult someone after they give you help?
    That's....polite.
     
  9. Unread #5 - Mar 29, 2007 at 7:01 PM
  10. Terrankiller
    Joined:
    May 7, 2005
    Posts:
    1,286
    Referrals:
    1
    Sythe Gold:
    1

    Terrankiller Ex-Administrator
    Retired Administrator Visual Basic Programmers

    react faster

    His name is: Flaming Idiots

    ... lol
     
  11. Unread #6 - Mar 30, 2007 at 12:38 AM
  12. speljohan
    Joined:
    Apr 24, 2005
    Posts:
    1,450
    Referrals:
    3
    Sythe Gold:
    0

    speljohan Guru
    Visual Basic Programmers

    react faster

    i think it was subliminal sarcasm :)
     
  13. Unread #7 - Mar 30, 2007 at 11:22 AM
  14. dodge
    Joined:
    Mar 26, 2007
    Posts:
    125
    Referrals:
    1
    Sythe Gold:
    5

    dodge Active Member
    Banned

    react faster

    at first when i read the post i was like WTF then i saw the name :) lol
     
  15. Unread #8 - Mar 31, 2007 at 4:49 PM
  16. kharg0
    Joined:
    Feb 25, 2007
    Posts:
    131
    Referrals:
    0
    Sythe Gold:
    0

    kharg0 Active Member

    react faster

    lol sry im not insulting him im saying his name lol :)
     
< Python Webbrowser | Help With NPCDrop (private server) >

Users viewing this thread
1 guest


 
 
Adblock breaks this site