再次更新 调整了画面 添加一了点声音 加快了速度 改用方向键操控
代码sheet1里 Private Sub CommandButton1_Click() Static aaa% aaa = aaa + 1 If aaa Mod 2 = 1 Then CommandButton1.Caption = "结束" cusi 29 dd Else CommandButton1.Caption = "开始" Range("b2:bg59").Interior.ColorIndex = 11 End End If End Sub Private Sub CommandButton1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) If KeyCode = 37 Then xx 1, 0 End If If KeyCode = 39 Then ' xx -1, 0 End If If KeyCode = 38 Then xx 0, 1 End If If KeyCode = 40 Then xx 0, -1 End If End Sub 模块里 Dim arr(1 To 2, 1 To 1), sjh%, sjl%, k%, arr2, arr1() Sub cusi(js) arr(1, 1) = js arr(2, 1) = js End Sub Sub xx(qjr, qji) Dim m As Date, js%, r%, abc% PauseTime = 0.1 Do DoEvents arr(1, 1) = arr(1, 1) - qjr arr(2, 1) = arr(2, 1) - qji If arr(1, 1) = 1 Or arr(1, 1) = 60 Then MsgBox "游戏结束": End If arr(2, 1) = 1 Or arr(2, 1) = 60 Then MsgBox "游戏结束": End If Cells(arr(2, 1), arr(1, 1)).Interior.ColorIndex = 45 Then MsgBox "游戏结束": End Start = Timer Do While Timer < Start + PauseTime Loop Range("b2:bg59").Interior.ColorIndex = 11 Cells(sjh, sjl).Interior.ColorIndex = 39 If k > 0 Then arr1(1, k + 1) = arr(1, 1) arr1(2, k + 1) = arr(2, 1) For mm = 1 To k Cells(arr1(2, mm), arr1(1, mm)).Interior.ColorIndex = 45 Next mm arr2 = arr1 For r = 1 To k arr1(1, r) = arr2(1, r + 1) arr1(2, r) = arr2(2, r + 1) Next r End If Cells(arr(2, 1), arr(1, 1)).Interior.ColorIndex = 39 arr2 = arr1 If arr(2, 1) = sjh And arr(1, 1) = sjl Then k = k + 1 ReDim Preserve arr1(1 To 2, 1 To k + 1) arr1(1, k) = arr(1, 1) arr1(2, k) = arr(2, 1) Beep dd End If Loop End Sub Sub dd() sjh = Int((58 * Rnd) + 2) sjl = Int((58 * Rnd) + 2) Cells(sjh, sjl).Interior.ColorIndex = 39 Cells(29, 29).Interior.ColorIndex = 39 End Sub
d3djEVz4.rar
(14.88 KB, 下载次数: 594)
[此贴子已经被作者于2008-7-27 3:53:12编辑过] |