📄 frmttt.frm
字号:
VERSION 5.00
Begin VB.Form frmTTT
BackColor = &H00C0E0FF&
Caption = "Tic Tac Toe"
ClientHeight = 7530
ClientLeft = 60
ClientTop = 345
ClientWidth = 8415
LinkTopic = "Form1"
ScaleHeight = 7530
ScaleWidth = 8415
Begin VB.TextBox txtTimeLimit
BeginProperty Font
Name = "Fixedsys"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 6480
TabIndex = 21
Top = 360
Width = 950
End
Begin VB.CommandButton cmdPlayers
Caption = "# Players"
BeginProperty Font
Name = "Fixedsys"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 735
Left = 1920
TabIndex = 14
Top = 1080
Width = 1335
End
Begin VB.Timer tmrTimer
Enabled = 0 'False
Interval = 100
Left = 240
Top = 2160
End
Begin VB.CommandButton cmdExit
Caption = "Exit Game"
BeginProperty Font
Name = "Fixedsys"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 735
Left = 3360
TabIndex = 13
Top = 1080
Width = 1335
End
Begin VB.CommandButton cmdNew
Caption = "New Game"
BeginProperty Font
Name = "Fixedsys"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 735
Left = 480
TabIndex = 12
Top = 1080
Width = 1335
End
Begin VB.Frame frmTTT
BackColor = &H00FF8080&
Height = 3555
Left = 840
TabIndex = 0
Top = 2040
Width = 3465
Begin VB.PictureBox pic9
BackColor = &H00FFFFFF&
ForeColor = &H000000C0&
Height = 1000
Left = 2280
ScaleHeight = 945
ScaleWidth = 945
TabIndex = 9
Top = 2400
Width = 1000
End
Begin VB.PictureBox pic8
BackColor = &H00FFFFFF&
ForeColor = &H000000C0&
Height = 1000
Left = 1200
ScaleHeight = 945
ScaleWidth = 945
TabIndex = 8
Top = 2400
Width = 1000
End
Begin VB.PictureBox pic7
BackColor = &H00FFFFFF&
ForeColor = &H000000C0&
Height = 1000
Left = 120
ScaleHeight = 945
ScaleWidth = 945
TabIndex = 7
Top = 2400
Width = 1000
End
Begin VB.PictureBox pic6
BackColor = &H00FFFFFF&
ForeColor = &H000000C0&
Height = 1000
Left = 2280
ScaleHeight = 945
ScaleWidth = 945
TabIndex = 6
Top = 1320
Width = 1000
End
Begin VB.PictureBox pic5
BackColor = &H00FFFFFF&
ForeColor = &H000000C0&
Height = 1000
Left = 1200
ScaleHeight = 945
ScaleWidth = 945
TabIndex = 5
Top = 1320
Width = 1000
End
Begin VB.PictureBox pic4
BackColor = &H00FFFFFF&
ForeColor = &H000000C0&
Height = 1000
Left = 120
ScaleHeight = 945
ScaleWidth = 945
TabIndex = 4
Top = 1320
Width = 1000
End
Begin VB.PictureBox pic3
BackColor = &H00FFFFFF&
ForeColor = &H000000C0&
Height = 1000
Left = 2280
ScaleHeight = 945
ScaleWidth = 945
TabIndex = 3
Top = 240
Width = 1000
End
Begin VB.PictureBox pic2
BackColor = &H00FFFFFF&
ForeColor = &H000000C0&
Height = 1000
Left = 1200
ScaleHeight = 945
ScaleWidth = 945
TabIndex = 2
Top = 240
Width = 1000
End
Begin VB.PictureBox pic1
BackColor = &H00FFFFFF&
ForeColor = &H000000C0&
Height = 1000
Left = 120
ScaleHeight = 945
ScaleWidth = 945
TabIndex = 1
Top = 240
Width = 1000
End
End
Begin VB.Label lblTimeMesg
BackColor = &H00C0E0FF&
Caption = "(Will take effect after new game selected)"
Height = 255
Left = 4920
TabIndex = 22
Top = 840
Width = 3135
End
Begin VB.Label lblTimeLimit
BackColor = &H00C0E0FF&
Caption = "Time Limit: "
BeginProperty Font
Name = "Fixedsys"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 5040
TabIndex = 20
Top = 405
Width = 1335
End
Begin VB.Label lblDraw
BackColor = &H00C0E0FF&
BeginProperty Font
Name = "Comic Sans MS"
Size = 15.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 735
Left = 4920
TabIndex = 19
Top = 4800
Width = 2895
End
Begin VB.Label lblO
BackColor = &H00C0E0FF&
BeginProperty Font
Name = "Comic Sans MS"
Size = 15.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 735
Left = 4920
TabIndex = 18
Top = 3960
Width = 2895
End
Begin VB.Label lblX
BackColor = &H00C0E0FF&
BeginProperty Font
Name = "Comic Sans MS"
Size = 15.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 735
Left = 4920
TabIndex = 17
Top = 3120
Width = 2895
End
Begin VB.Label lblTime
BackColor = &H00C0E0FF&
BeginProperty Font
Name = "Comic Sans MS"
Size = 15.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 615
Left = 4920
TabIndex = 16
Top = 2280
Width = 2895
End
Begin VB.Label lblPlayers
BackColor = &H00C0E0FF&
BeginProperty Font
Name = "Comic Sans MS"
Size = 15.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 615
Left = 4920
TabIndex = 15
Top = 1320
Width = 3255
End
Begin VB.Label lblMesg
BackColor = &H00C0E0FF&
BeginProperty Font
Name = "Comic Sans MS"
Size = 15.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 1335
Left = 840
TabIndex = 11
Top = 5880
Width = 3495
End
Begin VB.Label lblTTT
BackColor = &H00C0E0FF&
Caption = "Tic Tac Toe"
BeginProperty Font
Name = "Comic Sans MS"
Size = 27.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 735
Left = 840
TabIndex = 10
Top = 120
Width = 3135
End
End
Attribute VB_Name = "frmTTT"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'Muhamad Krad
Dim topLeft As Integer
Dim topMiddle As Integer
Dim topRight As Integer
Dim midLeft As Integer
Dim center As Integer
Dim midRight As Integer
Dim bottomLeft As Integer
Dim bottomMiddle As Integer
Dim bottomRight As Integer
Dim xScore As Integer 'number of games won by X
Dim oScore As Integer 'number of games won by O
Dim draw As Integer 'number of games drawn
Dim turnTime As Single 'time currently on the clock
Dim maxTime As Single 'maximum time alotted
Dim onePlayer As Boolean 'true if one player game
Dim xTurn As Boolean 'true if X's turn
Dim gameOver As Boolean 'true if game is over, i.e. if somebody wins
Dim taken(1 To 9) As Boolean
Private Sub cmdExit_Click()
End
End Sub
Private Sub cmdNew_Click()
'if a new time limit over 0 seconds is selected
If Val(txtTimeLimit.Text) > 0 Then
maxTime = Val(txtTimeLimit.Text)
Else
txtTimeLimit.Text = maxTime
End If
pic1.Cls
pic2.Cls
pic3.Cls
pic4.Cls
pic5.Cls
pic6.Cls
pic7.Cls
pic8.Cls
pic9.Cls
topLeft = 0
topMiddle = 0
topRight = 0
midLeft = 0
center = 0
midRight = 0
bottomLeft = 0
bottomMiddle = 0
bottomRight = 0
xTurn = True
gameOver = False
lblMesg = "X's Turn."
pic1.FontSize = 8
pic2.FontSize = 8
pic3.FontSize = 8
pic4.FontSize = 8
pic5.FontSize = 8
pic6.FontSize = 8
pic7.FontSize = 8
pic8.FontSize = 8
pic9.FontSize = 8
tmrTimer.Enabled = True
turnTime = 0
Dim i As Integer
For i = 1 To 9
taken(i) = False
Next i
End Sub
Private Sub cmdPlayers_Click()
If gameOver And onePlayer Then
onePlayer = False
lblPlayers.Caption = "Two Player Game."
ElseIf gameOver Then
onePlayer = True
lblPlayers.Caption = "One Player Game."
End If
End Sub
Private Sub Form_Load()
Randomize
topLeft = 0
topMiddle = 0
topRight = 0
midLeft = 0
center = 0
midRight = 0
bottomLeft = 0
bottomMiddle = 0
bottomRight = 0
xTurn = True
gameOver = True
lblMesg = "Toggle # Players and then select New Game."
lblPlayers.Caption = "One Player Game."
onePlayer = True
txtTimeLimit.Text = 5
maxTime = Val(txtTimeLimit.Text)
turnTime = 0
xScore = 0
oScore = 0
draw = 0
lblX.Caption = "X's Score: " + Str(xScore)
lblO.Caption = "O's Score: " + Str(oScore)
lblDraw.Caption = "Tie Games: " + Str(draw)
Dim i As Integer
For i = 1 To 9
taken(i) = False
Next i
End Sub
'Top left
Private Sub pic1_Click()
If Not gameOver Then
If topLeft = 0 Then
taken(1) = True
turnTime = 0
If xTurn Then
pic1.Print " ";
pic1.FontSize = 36
pic1.Print "X"
xTurn = False
topLeft = 1
If Not TTT Then
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -