Visual Basic 中学校 掲示板 投稿の管理
タグのない投稿を抽出
統計
RSS
Visual Basic 中学校
投稿一覧
vb2010で○×ゲームの作り方教えてくださいm(_ _)m
この投稿へのリンク
https://keijiban.umayadia.com/ThreadDetail.aspx?ThreadId=10582#CommentId22146
この投稿の削除
削除パスワード
削除する
コメント本文
投稿者
たかくん
 (社会人)
投稿日時
2011/11/22 03:43:52
続きです。
'人間の手番
Private Sub Man_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim Px, Py, x, y As Integer
For y = 0 To Cell - 1
For x = 0 To Cell - 1
If sender.tag = Boards(x, y).Tag Then Px = x : Py = y 'マウスの座標取得
Next
Next
'マークできるかどうか調べて"○"を置く
If Boards(Px, Py).Text = PASS Then Boards(Px, Py).Text = PLAYER Else Beep() : Exit Sub
ComputerAI()
If Jugement() = True Then MsgBox("PLAYERの勝ち") : Me.Close()
End Sub
Private Function Jugement() As Boolean
Dim x, y, p, c, i As Integer
For x = 0 To Cell - 1
p = 0 : c = 0
For y = 0 To Cell - 1
If Boards(x, y).Text = PLAYER Then p = p + 1
If Boards(x, y).Text = COM Then c = c + 1
If c = BINGO Then MsgBox("COMの勝ち") : Me.Close()
If p = BINGO Then Return True
Next
Next
For y = 0 To Cell - 1
p = 0 : c = 0
For x = 0 To Cell - 1
If Boards(x, y).Text = PLAYER Then p = p + 1
If Boards(x, y).Text = COM Then c = c + 1
If c = BINGO Then MsgBox("COMの勝ち") : Me.Close()
If p = BINGO Then Return True
Next
Next
p = 0 : c = 0
For i = 0 To Cell - 1
If Boards(i, i).Text = PLAYER Then p = p + 1
If Boards(i, i).Text = COM Then c = c + 1
If c = BINGO Then MsgBox("COMの勝ち") : Me.Close()
If p = BINGO Then Return True
Next
p = 0 : c = 0
For x = Cell - 1 To 0 Step -1
For y = 0 To Cell - 1
If x + y = 2 Then
If Boards(x, y).Text = PLAYER Then p = p + 1
If Boards(x, y).Text = COM Then c = c + 1
If c = BINGO Then MsgBox("COMの勝ち") : Me.Close()
If p = BINGO Then Return True
End If
Next
Next
Return False
End Function
Private Sub PutCom()
Dim Rx, Ry, x, y, Cnt As Integer
Cnt = 0
Rx = r.Next(0, Cell) : Ry = r.Next(0, Cell)
For y = 0 To Cell - 1
For x = 0 To Cell - 1
If Boards(x, y).Text <> PASS Then Cnt = Cnt + 1
Next
Next
If Cnt = Cell * Cell Then MsgBox("ドローです。") : Me.Close()
If Boards(Ry, Rx).Text = PASS Then
Boards(Ry, Rx).Text = COM
Else
PutCom()
End If
End Sub
End Class