I will start off explaining my problem in detail. When I start the game (I am making a snakes and ladders game with two dice that need random nubers) and I generate my both of my random numbers for both dice they are always the same number e.g. 3 and 3 or 4 and 4. I am new and I have searched for an answer but I really have no idea why thisis happening. Also, if you have the time, I have another problem and that is when I add the total of the two dice to the square number. What happens is that I want the square number to increase e.g. when it is on a 5, and I roll a 6 I want it to go to 11 and not just 6. I have a feeling that the problem is when I run the code: SquareNumber1 = SquareNumber1 + TotalAsInteger Here is the all of my code for player1, it is quite lengthy.
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'Creating random numbers and displaying them as labels.
Dim SquareNumber1 As Integer
Dim TotalAsInteger As Integer
Dim RandomGen1 As New Random
Dim RandomInt1 As Integer
RandomInt1 = RandomGen1.Next(2, 7)
Player1DiceRoll1.Text = CStr(RandomInt1)
Dim RandomGen2 As New Random
Dim RandomInt2 As Integer
RandomInt2 = RandomGen2.Next(2, 7)
Player1DiceRoll2.Text = CStr(RandomInt2)
TotalAsInteger = RandomInt2 + RandomInt1
Player1OutputLabel.Text = CStr(TotalAsInteger)
SquareNumber1 = SquareNumber1 + TotalAsInteger
'Change a the last label back to white.
If Label1.ForeColor = Color.Lime Then
Label1.ForeColor = Color.Black
ElseIf Label2.Forecolor = Color.Lime Then
Label2.ForeColor = Color.Black
ElseIf Label3.ForeColor = Color.Lime Then
Label3.ForeColor = Color.Black
ElseIf Label4.ForeColor = Color.Lime Then
Label4.ForeColor = Color.Black
ElseIf Label5.ForeColor = Color.Lime Then
Label5.ForeColor = Color.Black
ElseIf Label6.ForeColor = Color.Lime Then
Label6.ForeColor = Color.Black
ElseIf Label7.ForeColor = Color.Lime Then
Label7.ForeColor = Color.Black
ElseIf Label8.ForeColor = Color.Lime Then
Label8.ForeColor = Color.Black
ElseIf Label9.ForeColor = Color.Lime Then
Label9.ForeColor = Color.Black
ElseIf Label10.ForeColor = Color.Lime Then
Label10.ForeColor = Color.Black
ElseIf Label11.ForeColor = Color.Lime Then
Label11.ForeColor = Color.Black
ElseIf Label12.ForeColor = Color.Lime Then
Label12.ForeColor = Color.Black
ElseIf Label13.ForeColor = Color.Lime Then
Label13.ForeColor = Color.Black
ElseIf Label14.ForeColor = Color.Lime Then
Label14.ForeColor = Color.Black
ElseIf Label15.ForeColor = Color.Lime Then
Label15.ForeColor = Color.Black
ElseIf Label16.ForeColor = Color.Lime Then
Label16.ForeColor = Color.Black
ElseIf Label17.ForeColor = Color.Lime Then
Label17.ForeColor = Color.Black
ElseIf Label18.ForeColor = Color.Lime Then
Label18.ForeColor = Color.Black
ElseIf Label19.ForeColor = Color.Lime Then
Label19.ForeColor = Color.Black
ElseIf Label20.ForeColor = Color.Lime Then
Label20.ForeColor = Color.Black
ElseIf Label21.ForeColor = Color.Lime Then
Label21.ForeColor = Color.Black
ElseIf Label22.ForeColor = Color.Lime Then
Label22.ForeColor = Color.Black
ElseIf Label23.ForeColor = Color.Lime Then
Label23.ForeColor = Color.Black
ElseIf Label24.ForeColor = Color.Lime Then
Label24.ForeColor = Color.Black
ElseIf Label25.ForeColor = Color.Lime Then
Label25.ForeColor = Color.Black
ElseIf Label26.ForeColor = Color.Lime Then
Label26.ForeColor = Color.Black
ElseIf Label27.ForeColor = Color.Lime Then
Label27.ForeColor = Color.Black
ElseIf Label28.ForeColor = Color.Lime Then
Label28.ForeColor = Color.Black
ElseIf Label29.ForeColor = Color.Lime Then
Label29.ForeColor = Color.Black
ElseIf Label30.ForeColor = Color.Lime Then
Label30.ForeColor = Color.Black
ElseIf Label31.ForeColor = Color.Lime Then
Label31.ForeColor = Color.Black
ElseIf Label32.ForeColor = Color.Lime Then
Label32.ForeColor = Color.Black
ElseIf Label33.ForeColor = Color.Lime Then
Label33.ForeColor = Color.Black
ElseIf Label34.ForeColor = Color.Lime Then
Label34.ForeColor = Color.Black
ElseIf Label35.ForeColor = Color.Lime Then
Label35.ForeColor = Color.Black
ElseIf Label36.ForeColor = Color.Lime Then
Label36.ForeColor = Color.Black
ElseIf Label37.ForeColor = Color.Lime Then
Label37.ForeColor = Color.Black
ElseIf Label38.ForeColor = Color.Lime Then
Label38.ForeColor = Color.Black
ElseIf Label39.ForeColor = Color.Lime Then
Label39.ForeColor = Color.Black
ElseIf Label40.ForeColor = Color.Lime Then
Label40.ForeColor = Color.Black
ElseIf Label41.ForeColor = Color.Lime Then
Label41.ForeColor = Color.Black
ElseIf Label42.ForeColor = Color.Lime Then
Label42.ForeColor = Color.Black
ElseIf Label43.ForeColor = Color.Lime Then
Label43.ForeColor = Color.Black
ElseIf Label44.ForeColor = Color.Lime Then
Label44.ForeColor = Color.Black
ElseIf Label45.ForeColor = Color.Lime Then
Label45.ForeColor = Color.Black
ElseIf Label46.ForeColor = Color.Lime Then
Label46.ForeColor = Color.Black
ElseIf Label47.ForeColor = Color.Lime Then
Label47.ForeColor = Color.Black
ElseIf Label48.ForeColor = Color.Lime Then
Label48.ForeColor = Color.Black
ElseIf Label49.ForeColor = Color.Lime Then
Label49.ForeColor = Color.Black
End If
'Changing the new label to the right coloUr.
If SquareNumber1 = 1 Then
Label1.ForeColor = Color.Lime
ElseIf SquareNumber1 = 2 Then
Label2.ForeColor = Color.Lime
ElseIf SquareNumber1 = 3 Then
Label3.ForeColor = Color.Lime
ElseIf SquareNumber1 = 4 Then
Label4.ForeColor = Color.Lime
ElseIf SquareNumber1 = 5 Then
Label5.ForeColor = Color.Lime
ElseIf SquareNumber1 = 6 Then
Label6.ForeColor = Color.Lime
ElseIf SquareNumber1 = 7 Then
Label7.ForeColor = Color.Lime
ElseIf SquareNumber1 = 8 Then
Label8.ForeColor = Color.Lime
ElseIf SquareNumber1 = 9 Then
Label9.ForeColor = Color.Lime
ElseIf SquareNumber1 = 10 Then
Label10.ForeColor = Color.Lime
ElseIf SquareNumber1 = 11 Then
Label11.ForeColor = Color.Lime
ElseIf SquareNumber1 = 12 Then
Label12.ForeColor = Color.Lime
ElseIf SquareNumber1 = 13 Then
Label13.ForeColor = Color.Lime
ElseIf SquareNumber1 = 14 Then
Label14.ForeColor = Color.Lime
ElseIf SquareNumber1 = 15 Then
Label15.ForeColor = Color.Lime
ElseIf SquareNumber1 = 16 Then
Label16.ForeColor = Color.Lime
ElseIf SquareNumber1 = 17 Then
Label17.ForeColor = Color.Lime
ElseIf SquareNumber1 = 18 Then
Label18.ForeColor = Color.Lime
ElseIf SquareNumber1 = 19 Then
Label19.ForeColor = Color.Lime
ElseIf SquareNumber1 = 20 Then
Label20.ForeColor = Color.Lime
ElseIf SquareNumber1 = 21 Then
Label21.ForeColor = Color.Lime
ElseIf SquareNumber1 = 22 Then
Label22.ForeColor = Color.Lime
ElseIf SquareNumber1 = 23 Then
Label23.ForeColor = Color.Lime
ElseIf SquareNumber1 = 24 Then
Label24.ForeColor = Color.Lime
ElseIf SquareNumber1 = 25 Then
Label25.ForeColor = Color.Lime
ElseIf SquareNumber1 = 26 Then
Label26.ForeColor = Color.Lime
ElseIf SquareNumber1 = 27 Then
Label27.ForeColor = Color.Lime
ElseIf SquareNumber1 = 28 Then
Label28.ForeColor = Color.Lime
ElseIf SquareNumber1 = 29 Then
Label29.ForeColor = Color.Lime
ElseIf SquareNumber1 = 30 Then
Label30.ForeColor = Color.Lime
ElseIf SquareNumber1 = 31 Then
Label31.ForeColor = Color.Lime
ElseIf SquareNumber1 = 32 Then
Label32.ForeColor = Color.Lime
ElseIf SquareNumber1 = 33 Then
Label33.ForeColor = Color.Lime
ElseIf SquareNumber1 = 34 Then
Label34.ForeColor = Color.Lime
ElseIf SquareNumber1 = 35 Then
Label35.ForeColor = Color.Lime
ElseIf SquareNumber1 = 36 Then
Label36.ForeColor = Color.Lime
ElseIf SquareNumber1 = 37 Then
Label37.ForeColor = Color.Lime
ElseIf SquareNumber1 = 38 Then
Label38.ForeColor = Color.Lime
ElseIf SquareNumber1 = 39 Then
Label39.ForeColor = Color.Lime
ElseIf SquareNumber1 = 40 Then
Label40.ForeColor = Color.Lime
ElseIf SquareNumber1 = 41 Then
Label41.ForeColor = Color.Lime
ElseIf SquareNumber1 = 42 Then
Label42.ForeColor = Color.Lime
ElseIf SquareNumber1 = 43 Then
Label43.ForeColor = Color.Lime
ElseIf SquareNumber1 = 44 Then
Label44.ForeColor = Color.Lime
ElseIf SquareNumber1 = 45 Then
Label45.ForeColor = Color.Lime
ElseIf SquareNumber1 = 46 Then
Label46.ForeColor = Color.Lime
ElseIf SquareNumber1 = 47 Then
Label47.ForeColor = Color.Lime
ElseIf SquareNumber1 = 48 Then
Label48.ForeColor = Color.Lime
ElseIf SquareNumber1 >= 49 Then
Label49.ForeColor = Color.Lime
Dim Win As Integer = MsgBox("Well done, Mordor (Player1) won the game!", MessageBoxButtons.OK)
If Win = DialogResult.OK Then
End
Else
Button1.Enabled = False
Button2.Enabled = False
End If
ElseIf SquareNumber1 <= 0 Then
SquareNumber1 = 1
Label1.ForeColor = Color.Lime
End If
Button1.Enabled = False
Button2.Enabled = True
End Sub
Aucun commentaire:
Enregistrer un commentaire