想請大家幫幫忙
下星期二要交的一個程式設計小遊戲
下面是大概的雛形
而我們想要再有三個變化
1要如何改變字落下的速度還有增加字落下的個數
2若遊戲持續一分鐘則跳出對話框顯示你好優秀
3可有五次打錯的機會,並顯示出生命,而五次結束則跳出對話框顯示gameover
請大家幫忙
如有人能幫忙解出程式碼
萬分感激
Dim GameOn As Boolean
Dim Disp As String
Dim cTop(1 To 5), cLeft(1 To 5) As Single
Private Sub Form_Load()
Disp = "abcde"
GameOn = False
End Sub
Private Sub Form_Paint()
frmGame.CurrentX = 50
frmGame.CurrentY = picType.Height + 300
frmGame.Print "按F2鍵開始 F3鍵結束"
End Sub
Private Sub picType_KeyDown(KeyCode As Integer, Shift As Integer)
Dim i As Integer
If KeyCode = 113 Then 'F2
picType.Cls
For i = 1 To 5
cTop(i) = 0
Next
Timer1.Enabled = True
GameOn = True
ElseIf KeyCode = 114 Then 'F3
End
End If
End Sub
Private Sub picType_KeyPress(KeyAscii As Integer)
If GameOn Then
For i = 1 To 5
If cTop(i) <> 0 Then
If Chr(KeyAscii) = Mid$(Disp, i, 1) Then
picType.CurrentX = cLeft(i)
picType.CurrentY = cTop(i)
picType.Print " "
cTop(i) = 0
End If
End If
Next
End If
End Sub
Private Sub Timer1_Timer()
Dim i As Integer
For i = 1 To 5
If cTop(i) = 0 Then
cLeft(i) = i * 600 + 200
cTop(i) = 1
Mid$(Disp, i, 1) = Chr(97 + Int(Rnd * 26))
Exit Sub
Else
picType.CurrentX = cLeft(i)
picType.CurrentY = cTop(i)
picType.Print " "
cTop(i) = cTop(i) + 200
picType.CurrentX = cLeft(i)
picType.CurrentY = cTop(i)
picType.Print Mid(Disp, i, 1)
If cTop(i) > 2000 Then '死亡
picType.CurrentX = cLeft(i)
picType.CurrentY = cTop(i)
picType.Print " "
cTop(i) = 0
End If
End If
Next i
End Sub |