Hello
I am programming a timer for a game (Halo)
What needs to happen, is you select the level you want from the dropdown/combo box.
This will set the values of 4 timers, 1 for the Sniper Rifle, one for the Rocket Launcher, one for the Active-Camo and one for the Over-Shield.
I coded a Private Sub that Dim's 4 counters to a specified value depending on the SelectedIndex (the Map that is selected) of the group box.
When the Start button is clicked, I've coded the 4 timers to start, but they can't find the starting value set by the I coded in the "Private Sub GetTimes()"
How could I go about fixing this?
Below is the code.
I am programming a timer for a game (Halo)
What needs to happen, is you select the level you want from the dropdown/combo box.
This will set the values of 4 timers, 1 for the Sniper Rifle, one for the Rocket Launcher, one for the Active-Camo and one for the Over-Shield.
I coded a Private Sub that Dim's 4 counters to a specified value depending on the SelectedIndex (the Map that is selected) of the group box.
When the Start button is clicked, I've coded the 4 timers to start, but they can't find the starting value set by the I coded in the "Private Sub GetTimes()"
How could I go about fixing this?
Below is the code.
VB.NET:
Public Class Form1
Dim H1SRCount As Integer
Dim H1RLCount As Integer
Dim H1OSCount As Integer
Dim H1ACCount As Integer
#Region " Enumerations "
#End Region
#Region " Structures "
#End Region
#Region " Creation "
Private Sub frmHaloTimer_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
LoadHalo1()
End Sub
#End Region
#Region " Sub-Routines "
Private Sub LoadHalo1()
cbxH1GT.Enabled = False
btnStart.Enabled = False
btnReset.Enabled = False
btnPause.Enabled = False
End Sub
Private Sub LoadHalo2()
End Sub
Private Sub LoadHalo3()
End Sub
Private Sub GetTimes()
If cbxHalo1Map.SelectedIndex.ToString = "Blood Gluch" Then
Dim H1ACCount = 180
Dim H1OSCount = 60
Dim H1RLCount = 90
Dim H1SRCount = 120
End If
If cbxHalo1Map.SelectedIndex.ToString = "Sidewinder" Then
Dim H1ACCount = 60
Dim H1OSCount = 60
Dim H1RLCount = 120
Dim H1SRCount = 30
End If
If cbxHalo1Map.SelectedIndex.ToString = "Battle Creek" Then
Dim H1ACCount = 60
Dim H1OSCount = 60
Dim H1RLCount = 120
Dim H1SRCount = 30
End If
If cbxHalo1Map.SelectedIndex.ToString = "Derilect" Then
Dim H1ACCount = 60
Dim H1OSCount = 60
Dim H1RLCount = 30
Dim H1SRCount = 30
End If
If cbxHalo1Map.SelectedIndex.ToString = "Prisoner" Then
Dim H1ACCount = 60
Dim H1OSCount = 60
Dim H1RLCount = 120
Dim H1SRCount = 30
End If
If cbxHalo1Map.SelectedIndex.ToString = "Chirion TL34" Then
Dim H1ACCount = 45
Dim H1OSCount = 45
Dim H1RLCount = 45
Dim H1SRCount = 45
End If
If cbxHalo1Map.SelectedIndex.ToString = "Wizard" Then
Dim H1ACCount = 60
Dim H1OSCount = 60
Dim H1RLCount = 60
Dim H1SRCount = 60
End If
If cbxHalo1Map.SelectedIndex.ToString = "Damnation" Then
Dim H1ACCount = 60
Dim H1OSCount = 60
Dim H1RLCount = 120
Dim H1SRCount = 30
End If
If cbxHalo1Map.SelectedIndex.ToString = "Longest" Then
Dim H1ACCount = 60
Dim H1OSCount = 60
Dim H1RLCount = 60
Dim H1SRCount = 60
End If
If cbxHalo1Map.SelectedIndex.ToString = "Rat Race" Then
Dim H1ACCount = 90
Dim H1OSCount = 60
Dim H1RLCount = 60
Dim H1SRCount = 60
End If
If cbxHalo1Map.SelectedIndex.ToString = "Boarding Action" Then
Dim H1ACCount = 60
Dim H1OSCount = 60
Dim H1RLCount = 180
Dim H1SRCount = 30
End If
If cbxHalo1Map.SelectedIndex.ToString = "Hang 'em High" Then
Dim H1ACCount = 60
Dim H1OSCount = 180
Dim H1RLCount = 120
Dim H1SRCount = 30
End If
If cbxHalo1Map.SelectedIndex.ToString = "Chill Out" Then
Dim H1ACCount = 60
Dim H1OSCount = 60
Dim H1RLCount = 120
Dim H1SRCount = 60
End If
End Sub
Private Sub cbxHalo1Map_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbxHalo1Map.SelectedIndexChanged
'GetTimes()
btnStart.Enabled = True
btnReset.Enabled = True
btnPause.Enabled = True
End Sub
#End Region
#Region " Function "
Private Sub timeH1RL_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timeH1RL.Tick
lblH1RLTime.Text = H1RLCount.ToString()
If H1RLCount = 0 Then
timeH1RL.Enabled = False
lblH1RLTime.Text = "Done"
Else
H1RLCount -= 1
End If
End Sub
Private Sub timeH1OS_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timeH1OS.Tick
lblH1OSTime.Text = H1OSCount.ToString()
If H1OSCount = 0 Then
timeH1OS.Enabled = False
lblH1OSTime.Text = "Done"
Else
H1OSCount -= 1
End If
End Sub
Private Sub timeH1AC_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timeH1AC.Tick
lblH1ACTime.Text = H1ACCount.ToString()
If H1SRCount = 0 Then
timeH1AC.Enabled = False
lblH1ACTime.Text = "Done"
Else
H1ACCount -= 1
End If
End Sub
Private Sub timeH1SR_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timeH1SR.Tick
'GetTimes()
lblH1SRTime.Text = H1SRCount.ToString()
If H1SRCount = 0 Then
timeH1SR.Enabled = False
lblH1SRTime.Text = "Done"
Else
H1SRCount -= 1
End If
End Sub
#End Region
#Region " Variables "
#End Region
#Region " Event "
Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
GetTimes()
timeH1AC.Interval = 1000
timeH1AC.Enabled = True
timeH1SR.Interval = 1000
timeH1SR.Enabled = True
timeH1OS.Interval = 1000
timeH1OS.Enabled = True
timeH1RL.Interval = 1000
timeH1RL.Enabled = True
End Sub
#End Region
End Class