| 网站首页 | VB.Net实例分析 | .Net技术文摘 | 下载中心 | VB.Net书籍笔记 | .Net源码 | VBS脚本与组件调用 | Windows2008技术文摘 | 给我们留言 | 
最新公告:

  没有公告

您现在的位置: 乐博网 >> VB.Net实例分析 >> 游戏编程 >> 实例分析正文
最新推荐 更多内容
VB.Net扑克牌游戏的类
VB.Net扑克牌游戏的类
作者:Ilu    来源:乐博网整理     更新时间:2009-9-2

    Public Sub collect(ByVal nPlayer As Integer)
        'this sub collects cards in from the designated player id and sets location values to .
        For i As Integer = 0 To 51
            If activeDeck(i).PlayerID = CType(nPlayer, String) Then
                activeDeck(i).Location = "."
                activeDeck(i).PlayerID = "."
            End If
        Next
    End Sub

    Public Function Deal(ByVal nPlayer As Integer) As String
        'this sub deals a card to a nominated player and stores the player id in the active deck array
        Dim i As Integer = currentIndex

        If activeDeck(i).Location = "." Then
            If currentIndex >= 51 Then
                currentIndex = 0
            Else
                currentIndex = currentIndex + 1
            End If
            activeDeck(i).Location = "+"
            activeDeck(i).PlayerID = CType(nPlayer, String)
            Return activeDeck(i).CardType
        End If
    End Function

    Public Function returnCards(ByVal nplayer As Integer) As String
        Dim temp As String

        For i As Integer = 0 To 51
            If activeDeck(i).PlayerID = CType(nplayer, String) Then
                temp = temp & "," & activeDeck(i).CardType
            End If
        Next

        Return temp
    End Function

    Public Sub DrawCard(ByVal nCard As String, ByVal g As Graphics, ByVal x As Integer, ByVal y As Integer)
        Dim number As String 'will hold our face from our splitted string
        Dim isuit As String 'will hold our suit from our splited string
        Dim hdc As IntPtr = g.GetHdc() 'stores out gfx location

        'split the string will be in the format ("Suit.Face")
        Dim temp() As String = Split(nCard, ".")

        isuit = temp(0)
        number = temp(1)

        'calls 2 routines to transform the suit/face to correct words
        nSuit = convertSuit(isuit)
        nFace = convertFace(number)

        'draw our card and release the memory
        Try
            Dim Card As Integer = CType(Me.nFace, Integer) * 4 + nSuit
            cdtDrawExt(hdc, x, y, MyClass.width, MyClass.height, Card, 0, 0)
        Finally
            g.ReleaseHdc(hdc)
        End Try
    End Sub

    Public Sub drawBack(ByVal style As cardback, ByVal g As Graphics, ByVal x As Integer, ByVal y As Integer)
        Dim hdc As IntPtr = g.GetHdc()
        Try
            cdtDraw(hdc, x, y, style, 1, 0)
        Finally
            g.ReleaseHdc(hdc)
        End Try
    End Sub

    Public Sub Close()
        cdtTerm()
    End Sub

    Private Function convertFace(ByVal iFace As String) As Face
        Select Case iFace
            Case "1"
                Return Face.Ace
            Case "2"
                Return Face.Two
            Case "3"
                Return Face.Three
            Case "4"
                Return Face.Four
            Case "5"
                Return Face.Five
            Case "6"
                Return Face.Six
            Case "7"
                Return Face.Seven
            Case "8"
                Return Face.Eight
            Case "9"
                Return Face.Nine
            Case "10"
                Return Face.Ten
            Case "11"
                Return Face.Jack
            Case "12"
                Return Face.Queen
            Case "13"
                Return Face.King
        End Select
    End Function

    Private Function convertSuit(ByVal iSuit As String) As Suit
        Select Case iSuit
            Case "h"
                Return Suit.Heart
            Case "d"
                Return Suit.Club
            Case "s"
                Return Suit.Spade
            Case "c"
                Return Suit.Diamond
        End Select
    End Function


End Class

上一页  [1] [2] 

  • 上一篇:

  • 下一篇: 没有了
  • 【字体: 】【打印此文】【关闭窗口
      相关文章:(只显示最新16条)
    小游戏开发(VB2010实例)
    VB.Net制作2D地图引擎
    VB.NET编写扑克牌游戏的实例
    VB.NET游戏开发的实例

    | 设为首页 | 加入收藏 | 联系站长 | | 友情链接 | 版权申明 |
    乐博网欢迎各种媒体转载我们的原创作品[转载请注明出处];我们鼓励更多VB.Net开发者一起加入研究与探讨;如发现文章访问错误、内容错误或版权疑问、内容有违相关法律(如涉及政治、色情、反动或散布虚假有害信息)等情况,请及时向我们举报,我们将及时纠正!
    联系邮箱:Shiny#vip.qq.com (#替换为@) QQ交流群: 40797788 [闽ICP备05014267号]