作者skykegy (天邊的雲)
看板Visual_Basic
標題[VB6 ] 打地鼠遊戲,我的圖案顯示不出來
時間Wed Jun 29 20:56:15 2005
想嘗試做小遊戲,但發現它很難...>< 請教各位大大喔!
這是我的程式碼 是類似打地鼠那樣的
'紀錄老鼠狀態的陣列
Dim m_status(3) As Integer
_______________________________________________________________
Private Sub Form_Load()
Dim i As Integer
Randomize
'將老鼠狀態設定為0
For i = 0 To 3
m_status(i) = 0
Image1(i).Visible = False
Next i
End Sub
_______________________________________________________________
'在老鼠物件上按一下左鍵的副程式
Private Sub Image1_Click(Index As Integer)
Dim x As Integer
Image1(Index).Visible = False
m_status(Index) = 0
x = Val(Label2.Caption)
x = x + 10
Label2.Caption = Str(x)
End Sub
_______________________________________________________________
'控制老鼠顯示的時間事件程式
Private Sub Timer1_Timer()
Dim i, j, x As Integer
rlist = Array(0, 1, 2, 3)
For i = 0 To 3
j = Int(Rnd() * 4)
x = rlist(i)
rlist(i) = rlist(j)
rlist(j) = x
Next i
For i = 0 To 3
If m_status(rlist(i)) = 0 Then
m_status(rlist(i)) = 1
Image(rlist(i)).Visible = True
Exit For
End If
Next i
End Sub
我啟動後,程式根本沒跑耶!老鼠出不來...
是我在Timer的設定有錯嗎?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 60.244.51.26
1F:推 clifflu:先確定 Timer1.Enabled 屬性吧 220.129.68.25 06/29
2F:推 skykegy:是true耶,要改成false嗎? 60.244.51.26 06/29
3F:推 skykegy:有好心人願意解釋什麼是rlist嗎? 我不懂ijx三個 60.244.51.26 06/29
4F:推 BearWu:那個只是交換程式,類式撲克牌洗牌,以rlist做中 59.121.131.152 06/29
5F:→ BearWu:間轉換的媒介! 59.121.131.152 06/29
6F:推 fumizuki:Timer1.Interval 單位毫秒 210.58.156.43 06/30
7F:推 fumizuki:=1/1000秒 210.58.156.43 06/30
8F:推 skykegy:我成功了耶 好感動喔~謝謝大家 ^0^ 60.244.51.24 06/30