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

📄 invertedaabbox2d.vb

📁 一个.Net下用VB编写的用于游戏的人工智能引擎
💻 VB
字号:
'//  Desc:   v simple inverted (y increases down screen) axis aligned bounding
'//          box class

Public Class InvertedAABBox2D
    Dim m_vTopLeft As New Vector2D
    Dim m_vBottomRight As New Vector2D
    Dim m_vCenter As New Vector2D

    Public Sub New(ByVal tl As Vector2D, ByVal br As Vector2D)
        m_vTopLeft = tl
        m_vBottomRight = br
        m_vCenter = tl.Plus(br).Divided(2.0)
    End Sub

    '//returns true if the bbox described by other intersects with this one
    Public Function isOverlappedWith(ByVal other As InvertedAABBox2D) As Boolean
        Return Not ((other.Top() > Bottom()) Or (other.Bottom() < Top()) Or (other.Left() > Right()) Or (other.Right() < Left()))
    End Function

    Public ReadOnly Property TopLeft() As Vector2D
        Get
            Return m_vTopLeft
        End Get
    End Property
    Public ReadOnly Property BottomRight() As Vector2D
        Get
            Return m_vBottomRight
        End Get
    End Property

    Public ReadOnly Property Top() As Double
        Get
            Return m_vTopLeft.y
        End Get
    End Property

    Public ReadOnly Property Left() As Double
        Get
            Return m_vTopLeft.x
        End Get
    End Property

    Public ReadOnly Property Bottom()
        Get
            Return m_vBottomRight.y
        End Get
    End Property

    Public ReadOnly Property Right()
        Get
            Return m_vBottomRight.x
        End Get
    End Property

    Public ReadOnly Property Center() As Vector2D
        Get
            Return m_vCenter
        End Get
    End Property

    Public Sub Render(ByVal g As Graphics, ByVal RenderCenter As Boolean)
        Dim p As Pen = Pens.Black
        g.DrawLine(p, CInt(Left()), CInt(Top()), CInt(Right()), CInt(Top()))
        g.DrawLine(p, CInt(Left()), CInt(Bottom()), CInt(Right()), CInt(Bottom()))
        g.DrawLine(p, CInt(Left()), CInt(Top()), CInt(Left()), CInt(Bottom()))
        g.DrawLine(p, CInt(Right()), CInt(Top()), CInt(Right()), CInt(Bottom()))

        If (RenderCenter) Then
            g.DrawLine(p, CInt(m_vCenter.x - 5), CInt(m_vCenter.y - 5), 10, 10)
        End If
    End Sub
End Class

⌨️ 快捷键说明

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