'抄下後,鍵入於VB2010中,觀察執行結果。並請下載 linez 遊戲,試玩後比較了解,我們未完成的部份有哪些?
Public Class Form1
Dim p(81) As PictureBox
Dim pcolorMark(81) As Integer
Dim npColorMark(3) As Integer
Dim np(3) As PictureBox
Dim rBlank As Integer
Dim isBlank(81) As Boolean
Dim accScore = 0
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Randomize()
rBlank = 81
np(1) = PictureBox82
np(2) = PictureBox83
np(3) = PictureBox84
p(1) = PictureBox1
p(2) = PictureBox2
p(3) = PictureBox3
p(4) = PictureBox4
p(5) = PictureBox5
p(6) = PictureBox6
p(7) = PictureBox7
p(8) = PictureBox8
p(9) = PictureBox9
p(10) = PictureBox10
p(11) = PictureBox11
p(12) = PictureBox12
p(13) = PictureBox13
p(14) = PictureBox14
p(15) = PictureBox15
p(16) = PictureBox16
p(17) = PictureBox17
p(18) = PictureBox18
p(19) = PictureBox19
p(20) = PictureBox20
p(21) = PictureBox21
p(22) = PictureBox22
p(23) = PictureBox23
p(24) = PictureBox24
p(25) = PictureBox25
p(26) = PictureBox26
p(27) = PictureBox27
p(28) = PictureBox28
p(29) = PictureBox29
p(30) = PictureBox30
p(31) = PictureBox31
p(32) = PictureBox32
p(33) = PictureBox33
p(34) = PictureBox34
p(35) = PictureBox35
p(36) = PictureBox36
p(37) = PictureBox37
p(38) = PictureBox38
p(39) = PictureBox39
p(40) = PictureBox40
p(41) = PictureBox41
p(42) = PictureBox42
p(43) = PictureBox43
p(44) = PictureBox44
p(45) = PictureBox45
p(46) = PictureBox46
p(47) = PictureBox47
p(48) = PictureBox48
p(49) = PictureBox49
p(50) = PictureBox50
p(51) = PictureBox51
p(52) = PictureBox52
p(53) = PictureBox53
p(54) = PictureBox54
p(55) = PictureBox55
p(56) = PictureBox56
p(57) = PictureBox57
p(58) = PictureBox58
p(59) = PictureBox59
p(60) = PictureBox60
p(61) = PictureBox61
p(62) = PictureBox62
p(63) = PictureBox63
p(64) = PictureBox64
p(65) = PictureBox65
p(66) = PictureBox66
p(67) = PictureBox67
p(68) = PictureBox68
p(69) = PictureBox69
p(70) = PictureBox70
p(71) = PictureBox71
p(72) = PictureBox72
p(73) = PictureBox73
p(74) = PictureBox74
p(75) = PictureBox75
p(76) = PictureBox76
p(77) = PictureBox77
p(78) = PictureBox78
p(79) = PictureBox79
p(80) = PictureBox80
p(81) = PictureBox81
For i = 1 To 81
isBlank(i) = True
p(i).Left = ((i - 1) Mod 9) * 49 + 50
p(i).Top = ((i - 1) \ 9) * 42 + 100
pcolorMark(i) = 0
Next
For i = 1 To 3
np(i).Left = (i - 1 + 3) * 49 + 50
np(i).Top = 50
Next
Call next3colors()
Call computer_do_one_time()
End Sub
Sub next3colors()
For i = 1 To 3
Dim colorN = Int(Rnd() * 7) + 1
Select Case colorN
Case 1
np(i).Image = My.Resources.b1
npColorMark(i) = 1
Case 2
np(i).Image = My.Resources.b2
npColorMark(i) = 2
Case 3
np(i).Image = My.Resources.b3
npColorMark(i) = 3
Case 4
np(i).Image = My.Resources.b4
npColorMark(i) = 4
Case 5
np(i).Image = My.Resources.b5
npColorMark(i) = 5
Case 6
np(i).Image = My.Resources.b6
npColorMark(i) = 6
Case 7
np(i).Image = My.Resources.b7
npColorMark(i) = 7
End Select
Next
End Sub
Sub fillBlank(n As Integer)
Dim locN = Int(Rnd() * rBlank) + 1
Dim j = 1
Dim notBlankN = 0
While notBlankN < locN
If isBlank(j) = True Then notBlankN = notBlankN + 1
j = j + 1
End While
p(j - 1).Image = np(n).Image
isBlank(j - 1) = False
rBlank = rBlank - 1
pcolorMark(j - 1) = npColorMark(n)
End Sub
Sub computer_do_one_time()
Call fillBlank(1)
Call fillBlank(2)
Call fillBlank(3)
Call next3colors()
End Sub
Private Sub Form1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick
Call computer_do_one_time()
End Sub
Dim isClickFirst = True
Dim sourceCellN As Integer
Private Sub PictureBox1_MouseDown(sender As Object, e As MouseEventArgs) Handles PictureBox1.MouseDown, PictureBox2.MouseDown, PictureBox3.MouseDown, PictureBox4.MouseDown, PictureBox5.MouseDown,
PictureBox6.MouseDown, PictureBox7.MouseDown, PictureBox8.MouseDown, PictureBox9.MouseDown, PictureBox10.MouseDown,
PictureBox11.MouseDown, PictureBox12.MouseDown, PictureBox13.MouseDown, PictureBox14.MouseDown, PictureBox15.MouseDown,
PictureBox16.MouseDown, PictureBox17.MouseDown, PictureBox18.MouseDown, PictureBox19.MouseDown, PictureBox20.MouseDown,
PictureBox21.MouseDown, PictureBox22.MouseDown, PictureBox23.MouseDown, PictureBox24.MouseDown, PictureBox25.MouseDown,
PictureBox26.MouseDown, PictureBox27.MouseDown, PictureBox28.MouseDown, PictureBox29.MouseDown, PictureBox30.MouseDown,
Picturebox31.MouseDown, Picturebox32.MouseDown, Picturebox33.MouseDown, Picturebox34.MouseDown, Picturebox35.MouseDown,
Picturebox36.MouseDown, Picturebox37.MouseDown, Picturebox38.MouseDown, Picturebox39.MouseDown, PictureBox40.MouseDown,
Picturebox41.MouseDown, Picturebox42.MouseDown, Picturebox43.MouseDown, Picturebox44.MouseDown, Picturebox45.MouseDown,
Picturebox46.MouseDown, Picturebox47.MouseDown, Picturebox48.MouseDown, Picturebox49.MouseDown, PictureBox50.MouseDown,
Picturebox51.MouseDown, Picturebox52.MouseDown, Picturebox53.MouseDown, Picturebox54.MouseDown, Picturebox55.MouseDown,
Picturebox56.MouseDown, Picturebox57.MouseDown, Picturebox58.MouseDown, Picturebox59.MouseDown, PictureBox60.MouseDown,
Picturebox61.MouseDown, Picturebox62.MouseDown, Picturebox63.MouseDown, Picturebox64.MouseDown, Picturebox65.MouseDown,
Picturebox66.MouseDown, Picturebox67.MouseDown, Picturebox68.MouseDown, Picturebox69.MouseDown, PictureBox70.MouseDown,
Picturebox71.MouseDown, Picturebox72.MouseDown, Picturebox73.MouseDown, Picturebox74.MouseDown, Picturebox75.MouseDown,
Picturebox76.MouseDown, Picturebox77.MouseDown, Picturebox78.MouseDown, Picturebox79.MouseDown, PictureBox80.MouseDown,
PictureBox81.MouseDown
If e.Button = Windows.Forms.MouseButtons.Left Then
If isClickFirst = True Then
sourceCellN = Val(Microsoft.VisualBasic.Right(CType(sender, PictureBox).Name, 2))
If sourceCellN = 0 Then sourceCellN = Val(Microsoft.VisualBasic.Right(CType(sender, PictureBox).Name, 1))
p(sourceCellN).Size = New Size(p(sourceCellN).Size.Width + 10, p(sourceCellN).Size.Height + 10)
isClickFirst = False
Else
Dim objectCellN As Integer = Val(Microsoft.VisualBasic.Right(CType(sender, PictureBox).Name, 2))
If objectCellN = 0 Then objectCellN = Val(Microsoft.VisualBasic.Right(CType(sender, PictureBox).Name, 1))
p(sourceCellN).Size = New Size(p(sourceCellN).Size.Width - 10, p(sourceCellN).Size.Height - 10)
If (objectCellN <> sourceCellN) And isBlank(objectCellN) = True Then
p(objectCellN).Image = p(sourceCellN).Image
p(sourceCellN).Image = My.Resources.b0
isBlank(objectCellN) = False
isBlank(sourceCellN) = True
Call computer_do_one_time()
End If
isClickFirst = True
Call score()
End If
End If
End Sub
Sub score()
'
'
End Sub
End Class