我正在处理的 vb.net 程序中有三个问题。我正在创建一个骰子游戏,用户可以单击滚动,它会随机滚动并向他们展示他们滚动的骰子的图片。他们可以选择他们想玩多少筹码以及他们下注的数字。他们每次掷三个骰子。
以下是问题:
Duplicates - 当用户点击滚动和随机生成的数字时,其中两个是相同的,它不会显示其中一个。它应该显示其中之一
图像移入 Pictureboxes - 我试图让骰子图像移入 Pictureboxes,而不是让东西在播放时变得可见。
gui图片:http: //i.imgur.com/Kn6Nd.png
当前代码:
Dim do1 As Integer = rnd.Next(1, 7)
Dim do2 As Integer = rnd.Next(1, 7)
Dim do3 As Integer = rnd.Next(1, 7)
Dim do4 As Integer = rnd.Next(1, 7)
Dim do5 As Integer = rnd.Next(1, 7)
Dim do6 As Integer = rnd.Next(1, 7)
''Assign the appropriate image based on each die's value.
d1.Image = CType(My.Resources.ResourceManager.GetObject(String.Format("Die{0}", d1)), Image)
d2.Image = CType(My.Resources.ResourceManager.GetObject(String.Format("Die{0}", d2)), Image)
d3.Image = CType(My.Resources.ResourceManager.GetObject(String.Format("Die{0}", d3)), Image)
d4.Image = CType(My.Resources.ResourceManager.GetObject(String.Format("Die{0}", d1)), Image)
d5.Image = CType(My.Resources.ResourceManager.GetObject(String.Format("Die{0}", d2)), Image)
d6.Image = CType(My.Resources.ResourceManager.GetObject(String.Format("Die{0}", d3)), Image)
Dim iNumber As Integer
Dim iNumber2 As Integer
Dim iNumber3 As Integer
'purpose is to roll the dice and play the game.
'variables and declarations are here.
Dim chips As Integer = 100
If chkBet1.Checked = False And ChkBet2.Checked = False And chkBet3.Checked = False And chkBet4.Checked = False And chkBet5.Checked = False And chkBet6.Checked = False Then
MessageBox.Show("Please select a number to play")
Else
If txtChip1.Text = "" AndAlso txtChip2.Text = "" AndAlso txtChip3.Text = "" AndAlso txtChip4.Text = "" AndAlso txtChip5.Text = "" AndAlso txtChip6.Text = "" Then
MessageBox.Show("You must enter an amount.")
Else
'here we are randomizing the numbers for the game.
'iNumber = Int((6 * rnd()) + 1)
'iNumber2 = Int((6 * rnd()) + 1)
'iNumber3 = Int((6 * rnd()) + 1)
'this will show the dice if the number generated between 1-6 is automatically chosen.
If iNumber = 1 Then
d1.Visible = True
ElseIf iNumber = 2 Then
d2.Visible = True
ElseIf iNumber = 3 Then
d3.Visible = True
ElseIf iNumber = 4 Then
d4.Visible = True
ElseIf iNumber = 5 Then
d5.Visible = True
ElseIf iNumber = 6 Then
d6.Visible = True
End If
'this will show for the second dice.
If iNumber2 = 1 Then
d1.Visible = True
ElseIf iNumber2 = 2 Then
d2.Visible = True
ElseIf iNumber2 = 3 Then
d3.Visible = True
ElseIf iNumber2 = 4 Then
d4.Visible = True
ElseIf iNumber2 = 5 Then
d5.Visible = True
ElseIf iNumber2 = 6 Then
d6.Visible = True
End If
'this will show for the third dice.
If iNumber3 = 1 Then
d1.Visible = True
ElseIf iNumber3 = 2 Then
d2.Visible = True
ElseIf iNumber3 = 3 Then
d3.Visible = True
ElseIf iNumber3 = 4 Then
d4.Visible = True
ElseIf iNumber3 = 5 Then
d5.Visible = True
ElseIf iNumber3 = 6 Then
d6.Visible = True
End If
''this part is for the chips that they win. If they bet one chip, and one dice rolls a one, they got two chips.
If do1 = 1 AndAlso chkBet1.Checked Then
chips = "2"
ElseIf do2 = 2 AndAlso ChkBet2.Checked Then
chips = "4"
ElseIf do3 = 3 AndAlso chkBet3.Checked Then
chips = "6"
ElseIf iNumber = 4 AndAlso chkBet4.Checked Then
chips = "8"
ElseIf iNumber = 5 AndAlso chkBet5.Checked Then
chips = "10"
ElseIf iNumber = 6 AndAlso chkBet6.Checked Then
chips = "12"
End If
''second chip possible winnings.
If iNumber2 = 1 AndAlso chkBet1.Checked Then
chips = "2"
ElseIf iNumber2 = 2 AndAlso ChkBet2.Checked Then
chips = "4"
ElseIf iNumber2 = 3 AndAlso chkBet3.Checked Then
chips = "6"
ElseIf iNumber2 = 4 AndAlso chkBet4.Checked Then
chips = "8"
ElseIf iNumber2 = 5 AndAlso chkBet5.Checked Then
chips = "10"
ElseIf iNumber2 = 6 AndAlso chkBet6.Checked Then
chips = "12"
End If
'third chip possible winnings.
If iNumber3 = 1 AndAlso chkBet1.Checked Then
chips = "2"
ElseIf iNumber3 = 2 AndAlso ChkBet2.Checked Then
chips = "4"
ElseIf iNumber3 = 3 AndAlso chkBet3.Checked Then
chips = "6"
ElseIf iNumber3 = 4 AndAlso chkBet4.Checked Then
chips = "8"
ElseIf iNumber3 = 5 AndAlso chkBet5.Checked Then
chips = "10"
ElseIf iNumber3 = 6 AndAlso chkBet6.Checked Then
chips = "12"
End If
'chips are added up here by all
'chips = iNumber + chips '+ iNumber2 + iNumber3
lblChips.Text = chips
End If
End If
End Sub