private sub form1_keypress() if e.KeyCHar = "w" then ' do something end if if e.KeyChar = "d' then ' do something end if end sub
thnx
john




Posted 02 March 2007 - 07:41 PM
private sub form1_keypress() if e.KeyCHar = "w" then ' do something end if if e.KeyChar = "d' then ' do something end if end sub
Posted 02 March 2007 - 07:49 PM
Posted 02 March 2007 - 07:54 PM
William_Wilson, on 2 Mar, 2007 - 07:49 PM, said:
Posted 03 March 2007 - 05:47 AM
Option Explicit Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer Private Const VK_UP = &H26 Private Const VK_A = &H41 Private Const VK_D = &H44 Private Sub Form_Load() Timer1.Interval = 500 End Sub Private Sub Command1_Click() Timer1.Enabled = Not Timer1.Enabled End Sub Private Sub Timer1_Timer() Dim i As Integer Text1.Text = Hex$(GetAsyncKeyState(VK_A)) Text2.Text = Hex$(GetAsyncKeyState(VK_D)) End Sub
Posted 03 March 2007 - 01:39 PM
Public Class Form1
Dim left1 As Integer
Dim left2 As Integer
Dim top1 As Integer
Dim top2 As Integer
Dim change As Integer
Dim glitch As Boolean
Dim g1 As Boolean
Dim g2 As Boolean
Dim g3 As Integer
Dim g4 As Boolean
Dim g5 As Boolean
Dim istrue As Boolean
Dim which As Integer
Dim glitch2 As Boolean
Dim shot1 As Boolean
Dim shot2 As Boolean
Private Sub setstuff()
top1 = PictureBox1.Top
left1 = PictureBox1.Left
top2 = PictureBox2.Top
left2 = PictureBox2.Left
End Sub
Private Sub setpicturebox()
PictureBox1.Top = top1
PictureBox1.Left = left1
PictureBox3.Top = (PictureBox1.Top + 0)
PictureBox3.Left = (PictureBox1.Left + 42)
PictureBox2.Top = top2
PictureBox2.Left = left2
PictureBox4.Top = (PictureBox2.Top + 8)
PictureBox4.Left = (PictureBox2.Left - 16)
PictureBox5.Left = PictureBox3.Left
PictureBox5.Top = PictureBox3.Top - 16
PictureBox6.Left = PictureBox3.Left
PictureBox6.Top = PictureBox3.Top + 16
End Sub
Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress
If e.KeyChar = "^" Then
g4 = True
End If
If e.KeyChar = "&" Then
If g4 = True Then
g5 = True
End If
End If
If e.KeyChar = "*" Then
If g5 = True Then
change = 10
End If
End If
If e.KeyChar = "$" Then
If g5 = True Then
change = 30
End If
End If
If e.KeyChar = "!" Then
If g5 = True Then
glitch2 = True
End If
End If
If e.KeyChar = "~" Then
g1 = True
End If
If e.KeyChar = "`" Then
If g1 = True Then
g2 = True
End If
End If
If e.KeyChar = "@" Then
If g2 = True Then
glitch = True
End If
End If
If e.KeyChar = "%" Then
g3 = g3 + 1
If g3 = 3 Then
g1 = False
g2 = False
glitch = False
g3 = 0
End If
End If
If e.KeyChar = "w" Then
top1 = top1 - change
which = 1
End If
If e.KeyChar = "s" Then
top1 = top1 + change
which = 1
End If
If e.KeyChar = "a" Then
left1 = left1 - change
which = 1
End If
If e.KeyChar = "d" Then
left1 = left1 + change
which = 1
End If
If e.KeyChar = " " Then
If glitch2 = True Then
PictureBox5.Visible = True
PictureBox6.Visible = True
End If
PictureBox3.Visible = True
Timer1.Start()
End If
If e.KeyChar = "5" Then
PictureBox4.Visible = True
Timer2.Start()
End If
If e.KeyChar = "8" Then
top2 = top2 - change
which = 2
End If
If e.KeyChar = "2" Then
top2 = top2 + change
which = 2
End If
If e.KeyChar = "4" Then
left2 = left2 - change
which = 2
End If
If e.KeyChar = "6" Then
left2 = left2 + change
which = 2
End If
checkforbarriers()
If istrue = False Then
endo: setpicturebox()
End If
istrue = False
End Sub
Private Sub checkforbarriers()
If which = 1 Then
If left1 > 85 And left1 < 146 And top1 > 81 And top1 < 180 Then
istrue = True
left1 = PictureBox1.Left
top1 = PictureBox1.Top
End If
If left1 > 601 And left1 < 661 And top1 > 81 And top1 < 180 Then
istrue = True
left1 = PictureBox1.Left
top1 = PictureBox1.Top
End If
End If
If which = 2 Then
If left2 > 601 And left2 < 661 And top2 > 69 And top2 < 181 Then
istrue = True
left2 = PictureBox2.Left
top2 = PictureBox2.Top
End If
If left2 > 85 And left2 < 146 And top2 > 69 And top2 < 181 Then
istrue = True
left2 = PictureBox2.Left
top2 = PictureBox2.Top
End If
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Interval = (1)
Timer2.Interval = (1)
change = 3
setstuff()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
shot1 = True
If glitch = False Then
If glitch2 = False Then
PictureBox3.Left = PictureBox3.Left + 7
End If
If glitch2 = True Then
PictureBox3.Left = PictureBox3.Left + 7
PictureBox5.Left = PictureBox5.Left + 7
PictureBox6.Left = PictureBox6.Left + 7
End If
Else
If glitch2 = False Then
PictureBox3.Left = PictureBox3.Left + 20
End If
If glitch2 = True Then
PictureBox3.Left = PictureBox3.Left + 20
PictureBox5.Left = PictureBox5.Left + 20
PictureBox6.Left = PictureBox6.Left + 20
End If
End If
If PictureBox3.Left > 725 Then
Timer1.Stop()
PictureBox3.Top = (PictureBox1.Top + 0)
PictureBox3.Left = (PictureBox1.Left + 42)
PictureBox3.Visible = False
PictureBox5.Top = (PictureBox1.Top + 0)
PictureBox5.Left = (PictureBox1.Left + 42)
PictureBox5.Visible = False
PictureBox6.Top = (PictureBox1.Top + 0)
PictureBox6.Left = (PictureBox1.Left + 42)
PictureBox6.Visible = False
shot1 = False
End If
If PictureBox3.Left > PictureBox2.Left Then
If PictureBox3.Top > (PictureBox2.Top - 1) And PictureBox3.Top < (PictureBox2.Top + 42) Then
Timer1.Stop()
Timer2.Stop()
Panel1.Visible = True
MsgBox("Black Won")
GoTo endof
End If
End If
If PictureBox5.Left > PictureBox2.Left Then
If PictureBox5.Top > (PictureBox2.Top - 1) And PictureBox5.Top < (PictureBox2.Top + 42) Then
Timer1.Stop()
Timer2.Stop()
Panel1.Visible = True
MsgBox("Black Won")
GoTo endof
End If
End If
If PictureBox6.Left > PictureBox2.Left Then
If PictureBox6.Top > (PictureBox2.Top - 1) And PictureBox6.Top < (PictureBox2.Top + 42) Then
Timer1.Stop()
Timer2.Stop()
Panel1.Visible = True
MsgBox("Black Won")
GoTo endof
End If
End If
If PictureBox3.Left > 110 And PictureBox3.Left < 145 Then
If PictureBox3.Top > 109 And PictureBox3.Top < 180 Then
Timer1.Stop()
PictureBox3.Visible = False
PictureBox3.Top = (PictureBox1.Top + 0)
PictureBox3.Left = (PictureBox1.Left + 42)
End If
End If
If PictureBox3.Left > 627 And PictureBox3.Left < 662 Then
If PictureBox3.Top > 109 And PictureBox3.Top < 180 Then
Timer1.Stop()
PictureBox3.Visible = False
PictureBox3.Top = (PictureBox1.Top + 0)
PictureBox3.Left = (PictureBox1.Left + 42)
End If
End If
endof:
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
PictureBox4.Left = PictureBox4.Left - 7
If PictureBox4.Left < 2 Then
Timer1.Stop()
PictureBox4.Top = (PictureBox2.Top + 8)
PictureBox4.Left = (PictureBox2.Left - 16)
PictureBox4.Visible = False
End If
If PictureBox4.Left < PictureBox1.Left Then
If PictureBox4.Top > (PictureBox1.Top - 1) And PictureBox3.Top < (PictureBox2.Top + 28) Then
Timer1.Stop()
Timer2.Stop()
Panel1.Visible = True
MsgBox("Blue Won")
End If
End If
If PictureBox4.Left > 110 And PictureBox4.Left < 145 Then
If PictureBox4.Top > 109 And PictureBox4.Top < 180 Then
Timer2.Stop()
PictureBox4.Visible = False
PictureBox4.Top = (PictureBox2.Top + 8)
PictureBox4.Left = (PictureBox2.Left - 16)
End If
End If
If PictureBox4.Left > 627 And PictureBox4.Left < 662 Then
If PictureBox4.Top > 109 And PictureBox4.Top < 180 Then
Timer2.Stop()
PictureBox4.Visible = False
PictureBox4.Top = (PictureBox2.Top + 8)
PictureBox4.Left = (PictureBox2.Left - 16)
End If
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Close()
End Sub
Private Sub restart(ByVal Program As String)
For Each proc As Process In Process.GetProcesses
If proc.ProcessName = Program Then proc.Kill()
Next
Process.Start(Program)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
restart("Game")
Me.Close()
PictureBox1.Left = 21
PictureBox1.Top = 131
PictureBox3.Left = 67
PictureBox3.Top = 131
PictureBox2.Left = 688
PictureBox2.Top = 131
PictureBox4.Left = 762
PictureBox4.Top = 141
g1 = False
g2 = False
g3 = 0
glitch = False
change = 3
left1 = PictureBox1.Left
left2 = PictureBox2.Left
top1 = PictureBox1.Top
top2 = PictureBox2.Top
Panel1.Visible = False
PictureBox3.Visible = False
PictureBox4.Visible = False
End Sub
End Class
