关于随即函数Rnd()的问题!
要做个老鼠吃大米的游戏,棋盘上还有石头,撞到会死掉,吃掉一个米饭会在其他地方随即出现一个米饭,实现米饭随即出现的函数如下:Dim x(1 To 20) As Single: Dim y(1 To 20) As Single 'x y是棋盘坐标
Private Sub randrice(ByVal i As Integer)
Randomize Timer
For i = 0 To 4
mi(i).Left = x(Rnd() * 20): mi(i).Top = y(Rnd() * 20) 'mi(i)表示米饭数组
For j = 0 To 18
If mi(i).Left = stone(i).Left And mi(i).Top = stone(i).Top Then 'stone(i)是石头控件数组
mi(i).Left = x(Rnd() * 20): mi(i).Top = y(Rnd() * 20)
j = -1
End If
Next j
mi(i).Visible = True
Next i
End Sub
但是,当吃掉一个米饭后,其他米饭都不见,而且只出现在窗口的左上角上,请高手帮忙!