Dim j As Integer
Dim k As Integer
Dim X As String
Dim Y As String
Dim m As Integer
Dim n As Integer
Private Sub Command1_Click()
Label1.Caption = "该黑棋" &gamer1 &"走"
blackwhite = True
heibaiqi = True
Picture1.Cls
For i = 5 To -5 Step -1
Picture1.Line (-4.5, i - 0.5)-(4.5, i - 0.5)
QBColor (0)
Picture1.Line (i - 0.5, -4.5)-(i - 0.5, 4.5)
QBColor (0)
Next
For j = -4 To 4 Step -1
For k = -4 To 4 Step -1
a(j, k) = 0
Next
Next
a(j, k) = 0
Picture1.FillStyle = 0
Picture1.FillColor = QBColor(0)
Picture1.Circle (0, 0), 0.3, QBColor(0)
Picture1.Circle (1, 1), 0.3, QBColor(0)
Picture1.FillColor = QBColor(15)
Picture1.Circle (0, 1), 0.3, QBColor(15)
Picture1.Circle (1, 0), 0.3, QBColor(15)
End Sub
Private Sub Form_Load()
Form2.Picture1.Scale (-5, 5)-(5, -5)
Text1.Text = ""
End Sub
Private Sub kaishi_Click()
Label1.Caption = "该黑棋" + gamer1 + "走"
blackwhite = True
heibaiqi = True
Picture1.Cls
For i = 5 To -5 Step -1
Picture1.Line (-4.5, i - 0.5)-(4.5, i - 0.5)
QBColor (0)
Picture1.Line (i - 0.5, -4.5)-(i - 0.5, 4.5)
QBColor (0)
Next
For j = -4 To 4 Step -1
For k = -4 To 4 Step -1
a(j, k) = 0
Next
Next
a(j, k) = 0
Picture1.FillStyle = 0
Picture1.FillColor = QBColor(0)
Picture1.Circle (0, 0), 0.3, QBColor(0)
Picture1.Circle (1, 1), 0.3, QBColor(0)
Picture1.FillColor = QBColor(15)
Picture1.Circle (0, 1), 0.3, QBColor(15)
Picture1.Circle (1, 0), 0.3, QBColor(15)
End Sub
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If CInt(X) >= -4 And CInt(Y) >= -4 And heibaiqi = True Then
m = CInt(X)
n = CInt(Y)
Picture1.FillStyle = 0
If blackwhite = True And a(CInt(X), CInt(Y)) = 0 Then
Picture1.FillColor = QBColor(0)
Picture1.Circle (CInt(X), CInt(Y)), 0.3, QBColor(0)
a(CInt(X), CInt(Y)) = 1
Label1.Caption = "该白棋" &gamer2 &"走"
blackwhite = Not blackwhite
End If
If blackwhite = False And a(CInt(X), CInt(Y)) = 0 Then
Picture1.FillColor = QBColor(15)
Picture1.Circle (CInt(X), CInt(Y)), 0.3, QBColor(15)
a(CInt(X), CInt(Y)) = 2
Label1.Caption = "该黑棋" &gamer1 &"走"
blackwhite = Not blackwhite
End If
End If
'反转棋子
For i = 1 To 7
For j = 0 To i - 1
If a(CInt(X), CInt(Y)) = 1 And a(CInt(X) - i, CInt(Y)) = 1 And a(CInt(X) - i + j, CInt(Y)) = 2 Then
a(CInt(X) - i + j, CInt(Y)) = 1
End If
If a(CInt(X), CInt(Y)) = 1 And a(CInt(X), CInt(Y) - i) = 1 And a(CInt(X), CInt(Y) - i + j) = 2 Then
a(CInt(X), CInt(Y) - i + j) = 1
End If
If a(CInt(X), CInt(Y)) = 2 And a(CInt(X) - i, CInt(Y)) = 2 And a(CInt(X) - i + j, CInt(Y)) = 1 Then
a(CInt(X) - i + j, CInt(Y)) = 2
End If
If a(CInt(X), CInt(Y)) = 2 And a(CInt(X), CInt(Y) - i) = 2 And a(CInt(X), CInt(Y) - i + j) = 1 Then
a(CInt(X), CInt(Y) - i + j) = 2
End If
Next
Next
foe(i=-4i<=4i++)是
for(i=-4i<=4i++) 吧
绘9纵9横的棋盘 /*绘制水平方向的线*/
line(max_x/2-4*40 ,max_y/2+i*40, max_x/2+4*40, max_y/2+i*40)
起点x ,起点y,终点x,终点y 因为水平,所以第2 4个计算式是一样的
而且设计者设置了每行/每列间距为40 则棋盘正中间为最大x/2 最大y/2
每一行所在y为 最大y/2+行距(40)*行位(-4~+4 +/-表示在中间的上或下)
每一行X起止为 最大x/2±棋盘最大的一半(8*40/2)
竖线分析相同
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)