今天做了 井字遊戲

需要 都不用

程式碼如下

Public Class Form1
Dim Turn As Integer = 1
Dim w, h As Integer

Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
w = Me.ClientSize.Width \ 3
h = Me.ClientSize.Height \ 3
Dim g As Graphics = Me.CreateGraphics
g.DrawLine(Pens.Gray, 0, h, w * 3, h)
g.DrawLine(Pens.Gray, 0, h * 2, w * 3, h * 2)
g.DrawLine(Pens.Gray, w, 0, w, h * 3)
g.DrawLine(Pens.Gray, w * 2, 0, w * 2, h * 3)
g.Dispose()
End Sub

Private Sub Form1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick
Dim g As Graphics = Me.CreateGraphics
Dim x1, y1 As Integer
If e.X < w Then 'e.X取得滑鼠的X座標
x1 = 0
ElseIf e.X < w * 2 Then
x1 = w
Else
x1 = w * 2

ip612256374 發表在 痞客邦 留言(1) 人氣()