2008-01-16 23:48:53£´K

程式碼

Dim t As Integer ’turn
Dim used(8) As Integer
Dim gameover As Boolean
Dim n As Integer
Dim lv As Integer
-------------------------------------------------------
Sub hiplay()
t = -1
If used(4) = 0 Then
well(4).Picture = o.Picture
used(4) = t
t = -t
Else
If used(0) = 0 Then
well(0).Picture = o.Picture
used(0) = t
t = -t
Else
If used(6) = 0 Then
well(6).Picture = o.Picture
used(6) = t
t = -t
Else
If used(2) = 0 Then
well(2).Picture = o.Picture
used(2) = t
t = -t
Else
If used(8) = 0 Then
well(8).Picture = o.Picture
used(8) = t
t = -t
Else
midplay
checkwinner
End If
End If
End If
End If
End If







End Sub
----------------------------------------------------
Sub lowplay(i As Integer)
If i = 9 Then
midplay
Else
If used(i) = 0 Then
well(i).Picture = o.Picture
used(i) = t
t = -t
Else
midplay
End If
End If


End Sub
-----------------------------------------------------------
Sub midplay()
t = -1
Dim i
While used(i) <> 0
i = Int(Rnd * 9)
Wend
well(i).Picture = o.Picture
used(i) = t
t = -t
End Sub
Sub check(i, j, k As Integer)
p = used(i) + used(j) + used(k)
If p = -3 Then
MsgBox ”O Win”
gameover = True
End If
If p = 3 Then
MsgBox ”X Win”
gameover = True
End If
End Sub
Sub checkwinner()
check 0, 1, 2
check 3, 4, 5
check 6, 7, 8
check 0, 3, 6
check 1, 4, 7
check 2, 5, 8
check 0, 4, 8
check 2, 4, 6
If n = 9 And Not gameover Then
MsgBox ”no win and no lose”
gameover = True
End If

End Sub
----------------------------------------------
Private Sub Form_Load()
menu_newgame_Click
Randomize
lv = 0
End Sub

Private Sub menu_about_Click()
frmAbout.Show

End Sub

Private Sub menu_computer_Click()
menu_computer.Checked = True
lv = 0
End Sub
------------------------------------------------
Private Sub menu_easy_Click()
lv = 1
lowplay (i)
End Sub
-------------------------------------------------
Private Sub menu_end_Click()
Unload Me

End Sub

Private Sub menu_high_Click()
lv = 3
hiplay
End Sub
-----------------------------------------------------
Private Sub menu_newgame_Click()
For i = 0 To 8
used(i) = 0
well(i).Picture = Nothing
Next i
t = 1
gameover = False
n = 0

End Sub
--------------------------------------------------------
Private Sub menu_normal_Click()
lv = 2
midplay
End Sub

Private Sub well_Click(Index As Integer)
If gameover = False Then
If used(Index) = 0 Then
If t = -1 And lv = 0 Then
well(Index).Picture = o.Picture
Else
well(Index).Picture = x.Picture
End If
used(Index) = t
t = -t
n = n + 1
checkwinner
If lv = 3 And gameover = False Then
hiplay
checkwinner
End If
If lv = 2 And gameover = False Then
midplay
n = n + 1
checkwinner
End If
If lv = 1 And gameover = False Then
i = Index + 1
lowplay (i)
n = n + 1
checkwinner
End If

End If
Else

MsgBox ”Please start the new game”
End If
End Sub
看著這一大堆的程式碼
有著重複但并不相同

就像我們
有著相同的軀殼
卻不同的思想

就算相處同一平衡線上
也不能相處於同一點

那麼這個追逐的遊戲
何時才能結束呢?

如果我們一生出便開始執行
那麼是否到我們死去才能結束?

上一篇:FOR...

下一篇:

E.K 2008-01-23 14:06:57

係wo,...haha