我想做五子棋程序,希望高手提点意见,不会的也可以探讨一下。

解决方案 »

  1.   

    做个方的再用ico就行了,不一定非要圆的。
    api好像可以画圆的。
      

  2.   

    哪有见过方的棋子的啊?
    光picture=*。ico是不行的。
    api不太熟,怎么入手?
      

  3.   

    用GIF..
    先画好棋子...
    然后,用
    Microsoft Photo Editor(OFFICE自带,如果没有安装,可在OFFICE光盘中找到.)
    将其背景设置成透明即可...
      

  4.   

    做的是一个网络版的五子棋程序,试玩成功!
    只是首次加载窗体的时候需要等上5到6秒钟,第二次的话就不会如此了~~~~~~~~~~~~~~~~~以下是窗体的代码~~~~~~~~~~~~~~~~~~~~~~~~~~
    Option Explicit
    Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
    Dim blnServer As Boolean
    Dim blnStart As Boolean
    Dim blnReady As Boolean
    Dim blnWaitReady As Boolean
    Dim blnCend As Boolean
    Dim lngFirst&
    Dim lngWins&(2)Private Sub chkConnect()
        Select Case ChatTcp.State
        Case 0
            Label1.Caption = "Á¬½Ó¹Ø±Õ"
        Case 1
            Label1.Caption = "Á¬½Ó´ò¿ª"
        Case 2
            Label1.Caption = "ÕýÔÚÕìÌý"
        Case 3
            Label1.Caption = "¹ÒÆðÁ¬½Ó"
        Case 4
            Label1.Caption = "ÕýÔÚ½âÎöÖ÷»ú"
        Case 5
            Label1.Caption = "ÒѽâÎöÖ÷»ú"
        Case 6
            Label1.Caption = "ÕýÔÚÁ¬½Ó"
        Case 7
            Label1.Caption = "ÒÑÁ¬½Ó"
            cmdStart.Enabled = True
        Case 8
            Label1.Caption = "·þÎñÆ÷ÕýÔڹرÕÁ¬½Ó"
            If blnServer Then
                ChatTcp.Close
                ChatTcp.Listen
            End If
        Case 9
            Label1.Caption = "Á¬½Ó´íÎó"
        End Select
    End Sub内容太长待续!!!!!!!!!!!!!!!!!!!!!!
      

  5.   

    !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~接上~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ~~~~~~~~~~~~~~~~~以下是窗体的代码~~~~~~~~~~~~~~~~~~~~~~~~~~
    Private Sub ChatTcp_ConnectionRequest(ByVal requestID As Long)
        If ChatTcp.State <> sckClosed Then ChatTcp.Close
        ChatTcp.Accept requestID
    End SubPrivate Sub ChatTcp_DataArrival(ByVal bytesTotal As Long)
        Dim strData$, lngRow&, lngCol&
        
        ChatTcp.GetData strData
        If blnReady Then
            If strData = "Ready" Then
                blnStart = True
            End If
        Else
            If strData = "Ready" Then
                MsgBox "&para;&Ocirc;·&frac12;&Ograve;&Ntilde;&frac34;&shy;×&frac14;±&cedil;&ordm;&Atilde;&Aacute;&Euml;,&Ccedil;&euml;&iquest;&ordf;&Ecirc;&frac14;&pound;&iexcl;&pound;&iexcl;&pound;&iexcl;", vbOKOnly, "&Igrave;á&Ecirc;&frac34;&ETH;&Aring;&Iuml;&cent;"
                blnWaitReady = True
            End If
        End If
        If strData = "Start" And Label2.Caption <> "&Oacute;&Icirc;&Iuml;·&iquest;&ordf;&Ecirc;&frac14;" Then
            Label2.Caption = "&Oacute;&Icirc;&Iuml;·&iquest;&ordf;&Ecirc;&frac14;"
            ChatTcp.SendData "Start"
            If lngFirst Mod 2 = 1 Then
                myFiveChess.Enabled = True
            End If
        End If
        If Left(strData, 3) = "Row" Then
            myFiveChess.Enabled = True
            lngRow = CLng(Mid(strData, 4, 2))
            lngCol = CLng(Mid(strData, 9, 2))
            myFiveChess.Play lngRow, lngCol
        End If
        If Left(strData, 4) = "MSG_" Then
            txtContent = txtContent & Right(strData, Len(strData) - 4)
        End If
    End SubPrivate Sub cmdCut_Click()
        If ChatTcp.State <> 0 Then ChatTcp.Close
        cmdServerA.Enabled = True
        cmdServerC.Enabled = True
        txtServer.Enabled = True
        blnServer = False
    End SubPrivate Sub cmdCut_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        cmdBackColor Me, &HFFFFC0
        cmdCut.BackColor = vbWhite
    End SubPrivate Sub cmdServerA_Click()
        If Trim(txtServer) = "" Then
            MsgBox "&Ccedil;&euml;&Iuml;&Egrave;&Ecirc;&auml;&Egrave;&euml;&Ograve;&ordf;&micro;&Ccedil;&Acirc;&frac14;&micro;&Auml;·&thorn;&Icirc;&ntilde;&AElig;÷&Atilde;&ucirc;", vbCritical, "&acute;í&Icirc;ó&Igrave;á&Ecirc;&frac34;"
            txtServer.SetFocus
            Exit Sub
        End If
        
        cmdServerC.Enabled = False
        cmdServerA.Enabled = False
        If ChatTcp.State <> 0 Then ChatTcp.Close
        ChatTcp.RemoteHost = Trim(txtServer)
        ChatTcp.RemotePort = 1888
        ChatTcp.Connect
        lngFirst = 2
    End SubPrivate Sub cmdServerA_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        cmdBackColor Me, &HFFFFC0
        cmdServerA.BackColor = vbWhite
    End SubPrivate Sub cmdServerC_Click()
        Dim strServerName As String * 255
        Dim atIndex&
        
        If ChatTcp.State <> 0 Then ChatTcp.Close
        cmdServerA.Enabled = False
        cmdServerC.Enabled = False
        ChatTcp.LocalPort = 1888
        ChatTcp.Listen
        blnServer = True
        GetComputerName strServerName, 255
        atIndex = InStr(1, strServerName, Chr$(0))
        txtServer = Left(strServerName, atIndex - 1)
        txtServer.Enabled = False
        lngFirst = 1
    End SubPrivate Sub cmdServerC_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        cmdBackColor Me, &HFFFFC0
        cmdServerC.BackColor = vbWhite
    End SubPrivate Sub cmdStart_Click()
        If ChatTcp.State = 7 Then
            blnReady = True
            If blnWaitReady Then
                blnStart = True
                ChatTcp.SendData "Start"
                Label2.Caption = "&Oacute;&Icirc;&Iuml;·&iquest;&ordf;&Ecirc;&frac14;"
                If lngFirst Mod 2 = 1 Then
                    myFiveChess.Enabled = True
                End If
            Else
                Label2.Caption = "&micro;&Egrave;&acute;&yacute;&para;&Ocirc;·&frac12;&iquest;&ordf;&Ecirc;&frac14;"
                If ChatTcp.State = 7 And blnReady And Not myFiveChess.Enabled Then
                    ChatTcp.SendData "Ready"
                End If
            End If
        End If
    End SubPrivate Sub cmdStart_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        cmdBackColor Me, &HFFFFC0
        cmdStart.BackColor = vbWhite
    End SubPrivate Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        cmdBackColor Me, &HFFFFC0
    End SubPrivate Sub Frame2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        cmdBackColor Me, &HFFFFC0
    End SubPrivate Sub myFiveChess_Win(ByVal lngWin As Long)
        If lngFirst Mod 2 = lngWin Mod 2 Then
            lngWins(1) = lngWins(1) + 1
        Else
            lngWins(2) = lngWins(2) + 1
        End If
        lngFirst = lngFirst + 1
        If lngFirst Mod 2 <> 0 Then
            myFiveChess.Enabled = True
        Else
            myFiveChess.Enabled = False
        End If
        blnCend = False
    End SubPrivate Sub myFiveChess_&Acirc;&auml;×&Oacute;(ByVal lngStep As Long, ByVal RowStep As Long, ByVal ColStep As Long)
        If Not blnCend Then
            myFiveChess.Enabled = False
            blnCend = False
        End If
        ChatTcp.SendData "Row" & Format(CStr(RowStep), "00") & "Col" & Format(CStr(ColStep), "00")
    End SubPrivate Sub myFiveChess_&Iuml;&Acirc;&AElig;&aring;(ByVal lngStep As Long, ByVal RowStep As Long, ByVal ColStep As Long)
        Dim lngHand&, lngOtherHand&
            
        If lngFirst Mod 2 <> 0 Then
            If lngFirst Mod 2 <> lngStep Mod 2 Then
                lngHand = lngStep \ 2 + 1
                lngOtherHand = lngHand - 1
            Else
                lngHand = lngStep \ 2 + 1
                lngOtherHand = lngHand - 1
            End If
        Else
            If lngFirst Mod 2 <> lngStep Mod 2 Then '&frac12;&Oacute;&Ecirc;&Otilde;
                lngHand = lngStep \ 2 + 1
                lngOtherHand = lngHand
            Else '&Acirc;&auml;×&Oacute;'right
                lngHand = lngStep \ 2
                lngOtherHand = lngHand
            End If
        End If
        lblChessInfo(0).Caption = "±&frac34;&raquo;ú&micro;&Uacute;" & lngHand & "&Ecirc;&Ouml;"
        lblChessInfo(1).Caption = "&para;&Ocirc;·&frac12;&micro;&Uacute;" & lngOtherHand & "&Ecirc;&Ouml;"
        lblChessInfo(2).Caption = "±&frac34;&raquo;ú&Oacute;&reg;" & lngWins(1) & "&Aring;&Igrave;"
        lblChessInfo(3).Caption = "&para;&Ocirc;·&frac12;&Oacute;&reg;" & lngWins(2) & "&Aring;&Igrave;"
    End SubPrivate Sub Timer1_Timer()
        chkConnect
    End SubPrivate Sub txtName_GotFocus()
        txtBackColor Me, &HC0FFC0
        txtName.BackColor = vbWhite
    End SubPrivate Sub txtName_LostFocus()
        txtBackColor Me, &HC0FFC0
    End SubPrivate Sub txtSend_GotFocus()
        txtBackColor Me, &HC0FFC0
        txtSend.BackColor = vbWhite
    End SubPrivate Sub txtSend_KeyDown(KeyCode As Integer, Shift As Integer)
        Dim lngCtrlDown&
        
        lngCtrlDown = (Shift And vbCtrlMask) > 0
        If lngCtrlDown And KeyCode = vbKeyReturn Then
            msgSend
        End If
    End SubPrivate Sub msgSend()
        Dim strContent$
        If ChatTcp.State = 7 Then
            strContent = strContent & "[" & txtName & "]:" & txtSend & vbCrLf
            txtContent = txtContent & strContent
            txtContent.SelStart = Len(txtContent)
            txtSend = ""
            txtSend.SelStart = 0
            ChatTcp.SendData "MSG_" & strContent
        Else
            MsgBox "&Ccedil;&euml;&Iuml;&Egrave;&frac12;¨&Aacute;&cent;&Aacute;&not;&frac12;&Oacute;", vbCritical, "&acute;í&Icirc;ó&Igrave;á&Ecirc;&frac34;"
        End If
    End SubPrivate Sub txtSend_LostFocus()
        txtBackColor Me, &HC0FFC0
    End SubPrivate Sub txtServer_GotFocus()
        txtBackColor Me, &HC0FFC0
        txtServer.BackColor = vbWhite
    End SubPrivate Sub txtServer_LostFocus()
        txtBackColor Me, &HC0FFC0
    End Sub内容太长待续!!!!!!!!!!!!!!!!!!!!!!
      

  6.   

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~接上~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~以下是模块的代码~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    !!!!!!!!!!!!!**************接起来是一个完整的程序代码了!!!!!!!!!!!!!***********Public Sub cmdBackColor(ByRef frmTmp As Form, Optional lngColor& = &HE0E0E0)
        Dim ctlTmp As Control
        
        For Each ctlTmp In frmTmp.Controls
            If TypeOf ctlTmp Is CommandButton Then
                If ctlTmp.BackColor <> lngColor Then ctlTmp.BackColor = lngColor
            End If
        Next
    End SubPublic Sub txtBackColor(ByRef frmTmp As Form, Optional lngColor& = &HC0C0C0)
        Dim ctlTmp As Control
        
        For Each ctlTmp In frmTmp.Controls
            If TypeOf ctlTmp Is TextBox Then
                ctlTmp.BackColor = lngColor
            End If
        Next
    End SubPublic Function txtFormat$(ByVal strTxt$)
        txtFormat = Trim(Replace(strTxt, "'", "''"))
    End Function
      

  7.   

    一般是用这两句绘制棋子到棋盘上,而不是用圆形image控件
            pic.PaintPicture 模图,.... vbSrcAnd
            pic.PaintPicture 源图,.... vbSrcPaint
    先要图片,无论源或模都是矩形,这个是windows系统规则
    源图 棋子图片,要求棋子之外的空间全部涂成黑色
    模图 棋子图片的掩模,要求和棋子图片大小一致,相应棋子之外的空间全部涂成白色,棋子空间涂成白色解释:
    因为白色rgb为全1,黑色rpg为全0
    x and 0=0 ,x and 1=1,x or 1=1 ,x or 0=x
    这样将模图以And运算绘制到棋盘的结果是棋盘上出现一个棋子大小的黑孔,其它地方仍保持原样
    再将源图以or运算绘制到棋盘的结果是棋盘上实现了绘制一个棋子,其它地方仍保持原样不知你能不能看明白,不行你看图形方面的书好了
      

  8.   

    先要准备图片,无论源或模都是矩形,这个是windows系统规则
    源图 棋子图片,要求棋子之外的空间全部涂成黑色
    模图 棋子图片的掩模,要求和源图大小一致,相应棋子之外的空间全部涂成白色,棋子空间涂成黑色
    解释:
    因为白色rgb为全1,黑色rpg为全0
    x and 0=0 ,x and 1=x,x or 1=1 ,x or 0=x
    上面打错了,另外再详细一点
    x and 1=x,x or 1=1 表示这两种运算可以保持背景不变
    x and 0=0 ,x or 1=1  表示这两种运算可以是背景变白色或黑色
      

  9.   

    有几个方法可以实现:最简单的方法:先将你的棋子的图片作成椭圆型,并保存为“带透明色”的GIF,这样的GIF用IMAGE控件来加载显示出来就是你想要的形状了,低下的颜色在“透明色”区域不会被遮盖,这是一个最简单的方法。最烦琐的方法:就是建立不规则区域,方法比较复杂需要做边缘检测,创建多边形区域等等,要用到数个API(就象楼上那位朋友所用的方法),代码具有非常强烈的“炫目”作用,极不推荐使用。难度不高的方法:不使用任何控件,使用ALPHABLAND这个API来将你的棋子画到棋盘上,该API可以指定一个透明色,在贴图的时候指定的颜色将不会被贴到输出对象上,不过这个API在98下似乎不能使用,只在2000以上的系统中才被支持。
      

  10.   

    还是最简单的方法实用,顺便问下:picture属性设了之后,怎么直接再取消图片啊?(这个题10分)
      

  11.   

    选种属性栏的picture属性然后按DELELE键
      

  12.   

    在运行中直接用LoadPictrue而不加参数可以取消已赋予的图片.