Telkomisaloser
Ninja
I tried to create a program with a button that bounces when it hits a corner around in VB.net but so far it creates a few invisible walls and bouces within them
well heres the code it consists of 1 button called "woo" and four timers called timer1, timer2... and I enabled them and put them on 1 split second for each inteval. So heres the code, can any of you see the mistake
well heres the code it consists of 1 button called "woo" and four timers called timer1, timer2... and I enabled them and put them on 1 split second for each inteval. So heres the code, can any of you see the mistake
Code:
Dim xe As Integer = 0
Dim ye As Integer = 0
Dim xecontroller As Integer = 0
Dim yecontroller As Integer = 0
Dim xcontroler As Integer = 0
Dim ycontroler As Integer = 0
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If xe >= xcontroler Then
xecontroller = 1
ElseIf xe <= 0 Then
xecontroller = 0
End If
If xecontroller = 0 Then
xe = xe + 1
ElseIf xecontroller = 1 Then
xe = xe - 1
End If
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
If ye >= ycontroler Then
yecontroller = 1
ElseIf ye <= 0 Then
yecontroller = 0
End If
If yecontroller = 0 Then
ye = ye + 1
ElseIf yecontroller = 1 Then
ye = ye - 1
End If
End Sub
Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
woo.Location = (New Point(xe, ye))
End Sub
Private Sub woo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles woo.Click
xcontroler = Me.Location.X
ycontroler = Me.Location.Y
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
xcontroler = Me.Location.X
ycontroler = Me.Location.Y
End Sub