我今晚在家想编一个小游戏,是类似于螃蟹赛跑的小游戏,让玩家下注,买哪只小螃蟹赢。 编完了才发现其中的几只螃蟹在赛跑时总是胜出,在跑的过程中竟然有的还出现后退,我改了半天都不知道原因,请高手指点!!! 还有,请问如何解决螃蟹胜出的概率问题??? 部分代码: Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Dim n As Integer Dim a1 As Integer Dim a2 As Integer Dim a3 As Integer Dim a4 As Integer Dim a5 As Integer Dim b As Integer Dim speed As Integer While n <= 10 b = Int(10 * Rnd()) + 1 speed = 2 * (Int(5 * Rnd()) + 1) If b = 1 Then Me.PictureBox1.Left = Me.PictureBox1.Left + speed ElseIf b = 3 Then Me.PictureBox2.Left = Me.PictureBox2.Left + speed ElseIf b = 5 Then Me.PictureBox3.Left = Me.PictureBox3.Left + speed ElseIf b = 7 Then Me.PictureBox4.Left = Me.PictureBox5.Left + speed ElseIf b = 9 Then Me.PictureBox5.Left = Me.PictureBox5.Left + speed End If n = n + 1 End While End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Me.Timer1.Enabled = True End Sub