⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wuziclient.frm

📁 vb游戏程序代码
💻 FRM
📖 第 1 页 / 共 5 页
字号:
      End
   End
   Begin VB.PictureBox PicQipan 
      AutoRedraw      =   -1  'True
      BackColor       =   &H00C0E0FF&
      FillColor       =   &H80000006&
      ForeColor       =   &H80000006&
      Height          =   6375
      Left            =   120
      ScaleHeight     =   6315
      ScaleWidth      =   6075
      TabIndex        =   16
      Top             =   960
      Width           =   6135
   End
   Begin VB.Timer Timer1 
      Enabled         =   0   'False
      Interval        =   60000
      Left            =   6480
      Top             =   5760
   End
   Begin VB.CommandButton CmdMessage 
      Caption         =   "发送"
      Height          =   375
      Left            =   6360
      TabIndex        =   15
      Top             =   5520
      Width           =   615
   End
   Begin VB.TextBox MessageSend 
      Height          =   375
      Left            =   7200
      TabIndex        =   14
      Top             =   5520
      Width           =   3615
   End
   Begin VB.Frame Frame2 
      BackColor       =   &H80000000&
      Caption         =   "发送信息"
      Height          =   1215
      Left            =   6480
      TabIndex        =   9
      Top             =   6120
      Visible         =   0   'False
      Width           =   4335
      Begin VB.ComboBox UserChoose 
         Height          =   315
         Left            =   1080
         TabIndex        =   13
         Top             =   720
         Visible         =   0   'False
         Width           =   1455
      End
      Begin VB.ComboBox TalkWay 
         Height          =   315
         Left            =   1080
         TabIndex        =   12
         Text            =   "None"
         Top             =   360
         Width           =   1455
      End
      Begin VB.Label Label5 
         BackStyle       =   0  'Transparent
         Caption         =   "选择对象"
         Height          =   255
         Left            =   120
         TabIndex        =   11
         Top             =   720
         Visible         =   0   'False
         Width           =   735
      End
      Begin VB.Label Label4 
         BackStyle       =   0  'Transparent
         Caption         =   "选择方式"
         Height          =   255
         Left            =   120
         TabIndex        =   10
         Top             =   360
         Width           =   1095
      End
   End
   Begin VB.Frame Frame1 
      BackColor       =   &H80000000&
      Caption         =   "注册"
      Height          =   1215
      Left            =   6480
      TabIndex        =   1
      Top             =   6000
      Visible         =   0   'False
      Width           =   4335
      Begin VB.CommandButton login 
         Caption         =   "登陆"
         Default         =   -1  'True
         Height          =   975
         Left            =   3120
         TabIndex        =   8
         Top             =   240
         Width           =   1095
      End
      Begin VB.TextBox Email 
         Height          =   285
         Left            =   1320
         TabIndex        =   4
         Top             =   960
         Width           =   1695
      End
      Begin VB.TextBox Password 
         Height          =   285
         IMEMode         =   3  'DISABLE
         Left            =   1320
         PasswordChar    =   "*"
         TabIndex        =   3
         Top             =   600
         Width           =   1695
      End
      Begin VB.TextBox Nickname 
         Height          =   285
         Left            =   1320
         TabIndex        =   2
         Top             =   240
         Width           =   1695
      End
      Begin VB.Label Label3 
         BackStyle       =   0  'Transparent
         Caption         =   "e-mail"
         Height          =   255
         Left            =   240
         TabIndex        =   7
         Top             =   960
         Width           =   975
      End
      Begin VB.Label Label2 
         BackStyle       =   0  'Transparent
         Caption         =   "密 码"
         Height          =   255
         Left            =   240
         TabIndex        =   6
         Top             =   600
         Width           =   1335
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "昵 称"
         Height          =   195
         Left            =   240
         TabIndex        =   5
         Top             =   240
         Width           =   375
      End
   End
   Begin MSWinsockLib.Winsock TCP2 
      Left            =   6480
      Top             =   6480
      _ExtentX        =   741
      _ExtentY        =   741
      _Version        =   393216
      RemoteHost      =   "caojw"
      RemotePort      =   2002
   End
   Begin VB.TextBox MessageBox 
      CausesValidation=   0   'False
      Height          =   4095
      Left            =   6360
      Locked          =   -1  'True
      MultiLine       =   -1  'True
      ScrollBars      =   3  'Both
      TabIndex        =   0
      Top             =   480
      Width           =   4455
   End
   Begin MSComctlLib.ImageList ImageList1 
      Left            =   6000
      Top             =   2400
      _ExtentX        =   1005
      _ExtentY        =   1005
      BackColor       =   -2147483643
      ImageWidth      =   16
      ImageHeight     =   16
      MaskColor       =   12632256
      _Version        =   393216
      BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
         NumListImages   =   5
         BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "WuziClient.frx":04BF
            Key             =   ""
         EndProperty
         BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "WuziClient.frx":0A03
            Key             =   ""
         EndProperty
         BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "WuziClient.frx":0F47
            Key             =   ""
         EndProperty
         BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "WuziClient.frx":148B
            Key             =   ""
         EndProperty
         BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "WuziClient.frx":19CD
            Key             =   ""
         EndProperty
      EndProperty
   End
   Begin VB.Label WhiteName 
      Alignment       =   2  'Center
      BackStyle       =   0  'Transparent
      BorderStyle     =   1  'Fixed Single
      BeginProperty Font 
         Name            =   "楷体_GB2312"
         Size            =   14.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000000FF&
      Height          =   375
      Left            =   3240
      TabIndex        =   31
      Top             =   480
      Width           =   1620
   End
   Begin VB.Label BlackName 
      Alignment       =   2  'Center
      BackStyle       =   0  'Transparent
      BorderStyle     =   1  'Fixed Single
      BeginProperty Font 
         Name            =   "楷体_GB2312"
         Size            =   14.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000000FF&
      Height          =   375
      Left            =   1320
      TabIndex        =   30
      Top             =   480
      Width           =   1455
   End
   Begin VB.Menu mnuFile 
      Caption         =   "&File"
      Begin VB.Menu mnuFileNew 
         Caption         =   "&New"
      End
   End
End
Attribute VB_Name = "WuziClient"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'Dim AllUserNickname As String
'设定最大的连接人数为"8"
Const MaxConnect = 8
'设定数组AllUserss(MaxConnect)为结构体来保存用户信息
Dim AllUserss(MaxConnect) As AllUserInfo
'因为在网络系统中,经常有人进有人出,因此可以该数组来表示那些是空的,哪些是
'正在使用
Dim Use(MaxConnect) As Boolean
Dim TimeCount As Integer
'标记用户是否已经注册成功
Dim Connected As Boolean
'保存棋盘中棋子的位置
Dim DataArray(14, 14) As Integer
'MyColor为黑棋的颜色标志
Dim MyColor As Integer
'othercolor为白棋使用的颜色
Dim OtherColor As Integer
'用来标致是否轮到你下棋
Dim Drawing As Boolean
'用来存放每步棋的信息
Dim Buffer As String
Dim ErrorCode As Integer
'表示正在观战的棋局号
Dim WatchQiJu As Integer
'表示是否已经在对弈
Dim IfPlaying As Boolean
'表示正在下棋的棋局号
Dim PlayingNum As Integer
'定义开始下棋的时间
Dim Mytime
'说明是否是第一个棋子
Dim FirstStep As Boolean
'该变量标志是否为在本地机上玩
Dim LocalPlay As Boolean
Dim LocalPlayColor As Boolean
'表示是否胜利
Dim IfSucceed As Boolean
'表示是否在观战
Dim IfWatching As Boolean

'定义整盘棋的保留时间
Dim CanUseTime As Integer
'定义每步棋的时间
Dim EveryStepTime As Integer
'一共记时多少次
Dim TimeCanUseCount As Integer
'对弈方式
Dim Style As Integer
'保存时间的中间变量
Dim MidVariant

'定义画五子棋表格的每格长度和宽度
Const SubWidth = 400



'呼叫一个人和你对弈
Private Sub CallPlayer_Click()

If IfPlaying Then
    MessageBox.Text = MessageBox.Text & "你已经加入了一个棋局,你只有先退出," & _
    "然后才能加入新的棋局!"
    Exit Sub
End If

'如果呼叫对方的名字不为空
If Opponent.Text <> "" Then
        For i = 0 To MaxConnect
                '如果正在网上,则找出对手的用户代号
                If Use(i) Then
                    If AllUserss(i).Nickname = Opponent.Text Then
                            Usernumber = AllUserss(i).IndexNum
                            Exit For
                    End If
                End If
        Next

'选择对弈类型
Select Case PlayStyle.ListIndex
    Case 0
        Style = 0
    Case 1
        Style = 1
    Case 2
        Style = 2
    Case 3
        Style = 3
    Case 4
        Style = 4
End Select

                '根据不同的类型确定下棋的时间标准
                Select Case Style
                    Case 1
                        CanUseTime = 60
                        EveryStepTime = 60
                        TimeCanUseCount = 60
                    Case 2
                        
                        CanUseTime = 30
                        EveryStepTime = 30
                        TimeCanUseCount = 30
                    Case 3
                        CanUseTime = 10
                        EveryStepTime = 10
                        TimeCanUseCount = 10
                    Case 4
                        CanUseTime = 0
                        EveryStepTime = 10
                        TimeCanUseCount = 10
                    '表示自定义类型,在本程序中并没有实现其功能
                    Case 5
                End Select


'然后发送信息到服务器,在发送的过程中,首先发送"/P",这是自己规定的一些规则,
'这样当服务器接受到两个字符串的时候就知道是想找别人对弈,
'YourNickName表示自己的名字,Format(Usernumber, "000")表示将对手的用户代号
'格式化为"3",这是为了以后读取的时候方便,在各个字符串之间都是利用":"
'来隔开的,在服务器端则利用":"来读取出来的,style表示比赛类型,
'ColorChoose.ListIndex表示颜色索引

TCP2.SendData "/P:" & YourNickName & ":" & Format(Usernumber, "000") & ":" & Style & ":" & ColorChoose.ListIndex

'确定自己选择的颜色
If ColorChoose.ListIndex = 0 Then
    MyColor = 0
Else
    MyColor = 1
End If


Else
    MsgBox "请选择对手", vbCritical, "注意!"
    Exit Sub
End If

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -