我在試著做 Iphone 遊戲 1 to 50 我改成 1 to 25 容易點 XDD 可是還是有點問題
我的code是
-
- Dim Backcounter As Integer
- Dim Buttons(1 To 25) As Integer
- Private Sub Form_Load()
- Dim counta As Integer
- Randomize Timer
- Timer1.Interval = 10
- Timer2.Interval = 3000
- lblTimer.Caption = "00:00.00"
- lblBackcounter.Caption = "Ready"
- lblBackcounter.Enabled = True
- Timer2.Enabled = True
- lblNumber.Caption = 1
- numbercoutner = 1
- missed = 0
- lblMissedNumber.Caption = 0
- Time_Count = 0 'reset counter for new record
- Backcounter = 0 'make sure the "Ready" will come out (Backounter < 0)
- Call Swap
- For counta = 1 To 25
-
- Buttons(counta) = counta
-
- Next
- For counta = 1 To 25
- lblButtons(counta).Caption = Buttons(counta)
-
- Next
- End Sub
- Private Sub lblButtons_Click(Index As Integer)
- If counta = numbercounter Then
- numbercounter = numbercounter + 1
-
- Else: missed = missed + 1 ' update the worry clcik
- End If
- If numbercounter = 26 Then 'finished 25 number
- Game_Start = False
-
- frmEnterName.Show 'call out the Name from
-
-
- End If
- End Sub
- Private Sub lblMissedNumber_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
- lblMissedNumber.Caption = missed
- End Sub
- Private Sub Timer1_Timer()
- Dim lSec As Long
- Dim lMin As Long
- Dim lminsec As Long
- If Timer2.Enabled = False Then
- Time_Count = Time_Count + 1
- lMin = Time_Count \ 6000
- lSec = (Time_Count Mod 6000) \ 100
- lminsec = Time_Count Mod 100
- lblTimer.Caption = Format(lMin, "00") & ":" & Format(lSec, "00") & "." & Format(lminsec, "00")
- Scores = lblTimer.Caption
- End If
- End Sub
- Private Sub Timer2_Timer()
- Backcounter = Backcounter - 1
- lblBackcounter.Caption = Backcounter
- If Backcounter < 0 Then
- lblBackcounter.Caption = ""
-
- lblBackcounter.Enabled = False
-
- Timer2.Enabled = False
-
-
- End If
- End Sub
- Sub Swap() 'doing sWap in the RAM
- Dim loc1, loc2, counta, temp As Integer
- For counta = 1 To 500
- loc1 = Int(Rnd * 25) + 1
- loc2 = Int(Rnd * 25) + 1
- temp = Buttons(loc1)
- Buttons(loc1) = Buttons(loc2)
- Buttons(loc2) = temp
- Next
- End Sub
複製代碼
我的想法就是 讓程式在 記憶體 作交換位子的是
然後再打她叫出還用
可是好像沒有換位子
- Sub Swap() 'doing sWap in the RAM
- Dim loc1, loc2, counta, temp As Integer
- For counta = 1 To 500
- loc1 = Int(Rnd * 25) + 1
- loc2 = Int(Rnd * 25) + 1
- temp = Buttons(loc1)
- Buttons(loc1) = Buttons(loc2)
- Buttons(loc2) = temp
- Next
- End Sub
-
- Call Swap
- For counta = 1 To 25
- Buttons(counta) = counta
- Next
- For counta = 1 To 25
- lblButtons(counta).Caption = Buttons(counta)
- Next
複製代碼
上面是我做交換的code 讓他在記憶體 換500次位子
但是出來還是沒用 = =
那數字是 lblButtons(1) 到 lblButtons(25)
還有
- Private Sub lblButtons_Click(Index As Integer)
- If counta = numbercounter Then
- numbercounter = numbercounter + 1
- Else: missed = missed + 1 ' update the worry clcik
- End If
- If numbercounter = 26 Then 'finished 25 number
- Game_Start = False
- frmEnterName.Show 'call out the Name from
- End If
- End Sub
複製代碼
這我想寫說 當遊戲開始 然後 當 lblNumber = 被點到的 lblButtons 數字
numbercounter會+1
然後 numbercounter = 26 就是說 25個數字都點對了 所以就結束
當 lblNumber <> 被點到的 lblButtons 數字
missed 會 +1
然後 lblmissednumber.caption = missed
最後我想多加 當
- Game_Start = False
- frmEnterName.Show 'call out the Name from
複製代碼
可以順便 紀錄所花的時間 就是 Scores = lblTimer.Caption
當遊戲結束 我的 紀錄名子的Form 就會出來
但是 有人可以教我一下 排名的方法 (氣泡排序法)
我會紀錄 時間 名子 然後Time_Count 用最少的是第一名
然後 排名只會Show 名次 名子 時間 不要把 Time_Count show 出來
排名的程式 我都找不到例子 練習所以不會寫
雖然有很多問題 但是希望 可以把這小遊戲 做完美一點 ^.^ 謝謝... |