• Log in or sign up for an account here: https://www.sythe.org/login

react faster

kharg0

Active Member
Joined
Feb 25, 2007
Sythe Gold
0
Messages
131
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
 
Two Factor Authentication User
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.
 
alright thx flaming idiots
 
at first when i read the post i was like WTF then i saw the name :) lol
 
lol sry im not insulting him im saying his name lol :)
 
Runescape Gamblingrunescape gambling
Back
Top