Hi i am trying learn off youtube trying to follow of tutorials from games and currently i am stuck on a part where i am making a mouse cursor game but i am not able to make the label move side to side in the timer tick part of the code. my code is as followed.
Public Class level4
Shadows menu = New menu
Private hoverstart As Boolean
Private hoverleft As Boolean
Private hoverCount As Integer
Dim startRun As Boolean
Dim second As Integer
Dim minute As Integer
Dim total As Integer
Sub cursorStart()
Dim startCursor = startbtn.Location()
startCursor.Offset(24, 20)
Cursor.Position = PointToScreen(startCursor)
End Sub
Private Sub startbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles startbtn.Click
'starts timer for level 4
startRun = True
startbtn.Visible = False
finishlbl.Visible = True
Timer1.Enabled = True
End Sub
Private Sub level4_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.MouseEnter
If startRun = True Then
startRun = False
startbtn.Visible = True
finishlbl.Visible = False
Timer1.Enabled = False
Timer2.Enabled = False
minute = 0
second = 0
total = 0
timelbl.Text = "00:00"
MsgBox("You Lose, You went into the yellow area")
cursorStart()
End If
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
second += 1
If second > 59 Then
minute += 1
second = 0
End If
timelbl.Text = minute.ToString.PadLeft(2, "0"c) & ":" & second.ToString.PadLeft(2, "0"c)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
menu.show()
Me.Close()
End Sub
Private Sub finishlbl_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles finishlbl.Click
Timer1.Enabled = False
Me.Close()
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
If startRun = True Then
If hoverstart = True Then 'if you click the first start transpad button
If hoverleft = True Then 'if the transpad can move left
hover1lbl.Left += 5 'this moves it right 5 pixels
hoverCount += 5 'increase the count by 5
If hoverCount >= 170 Then 'if the count is >= 170
hoverleft = False 'transped has to move left
End If
End If
hover1lbl.Left -= 5 'moves it Left 5 pixels
hoverCount -= 5 'decrease count by 5
If hoverCount <= 0 Then 'if the count <= 0...
hoverleft = True ' transped has to move rigth
End If
End If
End If
End Sub
Private Sub hover1start_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles starthover1.Click
Timer2.Enabled = True
End Sub
End Class
the timer2 is the part of the code that has the code written in it, and the hover1 start click where it enables timer2 to be true is where the user clicks on the laber to activates the timer to make it start moving. however it is not working. any help please?
the video i watched is this towards the end
https://www.youtube.com/watch?v=drSbTyrvVZI
Public Class level4
Shadows menu = New menu
Private hoverstart As Boolean
Private hoverleft As Boolean
Private hoverCount As Integer
Dim startRun As Boolean
Dim second As Integer
Dim minute As Integer
Dim total As Integer
Sub cursorStart()
Dim startCursor = startbtn.Location()
startCursor.Offset(24, 20)
Cursor.Position = PointToScreen(startCursor)
End Sub
Private Sub startbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles startbtn.Click
'starts timer for level 4
startRun = True
startbtn.Visible = False
finishlbl.Visible = True
Timer1.Enabled = True
End Sub
Private Sub level4_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.MouseEnter
If startRun = True Then
startRun = False
startbtn.Visible = True
finishlbl.Visible = False
Timer1.Enabled = False
Timer2.Enabled = False
minute = 0
second = 0
total = 0
timelbl.Text = "00:00"
MsgBox("You Lose, You went into the yellow area")
cursorStart()
End If
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
second += 1
If second > 59 Then
minute += 1
second = 0
End If
timelbl.Text = minute.ToString.PadLeft(2, "0"c) & ":" & second.ToString.PadLeft(2, "0"c)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
menu.show()
Me.Close()
End Sub
Private Sub finishlbl_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles finishlbl.Click
Timer1.Enabled = False
Me.Close()
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
If startRun = True Then
If hoverstart = True Then 'if you click the first start transpad button
If hoverleft = True Then 'if the transpad can move left
hover1lbl.Left += 5 'this moves it right 5 pixels
hoverCount += 5 'increase the count by 5
If hoverCount >= 170 Then 'if the count is >= 170
hoverleft = False 'transped has to move left
End If
End If
hover1lbl.Left -= 5 'moves it Left 5 pixels
hoverCount -= 5 'decrease count by 5
If hoverCount <= 0 Then 'if the count <= 0...
hoverleft = True ' transped has to move rigth
End If
End If
End If
End Sub
Private Sub hover1start_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles starthover1.Click
Timer2.Enabled = True
End Sub
End Class
the timer2 is the part of the code that has the code written in it, and the hover1 start click where it enables timer2 to be true is where the user clicks on the laber to activates the timer to make it start moving. however it is not working. any help please?
the video i watched is this towards the end
https://www.youtube.com/watch?v=drSbTyrvVZI