コード例 #1
0
ファイル: CollisionLine.cs プロジェクト: theKyuu/GLhf
 public CollisionLine(Vector2 a_start, Vector2 a_end)
 {
     m_position = new CartesianCoordinate(a_start);
     m_endPosition = new CartesianCoordinate(a_end);
     m_OutBox.X = (int)Math.Floor(Math.Min(m_position.getGlobalX(), m_endPosition.getGlobalX()));
     m_OutBox.Y = (int)Math.Floor(Math.Min(m_position.getGlobalY(), m_endPosition.getGlobalY()));
     m_OutBox.Width = (int)Math.Floor(Math.Abs(Math.Max(m_position.getGlobalX(), m_endPosition.getGlobalX()) - Math.Min(m_position.getGlobalX(), m_endPosition.getGlobalX())));
     m_OutBox.Height = (int)Math.Floor(Math.Abs(Math.Max(m_position.getGlobalY(), m_endPosition.getGlobalY()) - Math.Min(m_position.getGlobalY(), m_endPosition.getGlobalY())));
 }
コード例 #2
0
ファイル: CollisionTriangle.cs プロジェクト: Yuma-Shi/GLhf
        public CollisionTriangle(Vector2[] a_points, Position a_position)
        {
            if (a_points == null)
            {
                throw new ArgumentNullException("points in triangle cannot be null");
            }
            if (a_position == null)
            {
                throw new ArgumentNullException("position for triangle cannot be null");
            }
            if (a_points.Length != 3)
            {
                throw new ArgumentException("triangle needs exactly 3 points, got " + a_points.Length);
            }
            m_AOffset = a_points[0];
            m_BOffset = a_points[1];
            m_COffset = a_points[2];
            m_position = a_position;

            int t_lowestX = (int)Math.Floor(Math.Min(Math.Min(m_AOffset.X,m_BOffset.X),m_COffset.X) + m_position.getGlobalX());
            int t_lowestY = (int)Math.Floor(Math.Min(Math.Min(m_AOffset.Y, m_BOffset.Y), m_COffset.Y) + m_position.getGlobalY());
            int t_width = (int)Math.Ceiling(Math.Max(Math.Max(m_AOffset.X, m_BOffset.X), m_COffset.X) - Math.Min(Math.Min(m_AOffset.X, m_BOffset.X), m_COffset.X));
            int t_height = (int)Math.Ceiling(Math.Max(Math.Max(m_AOffset.Y, m_BOffset.Y), m_COffset.Y) - Math.Min(Math.Min(m_AOffset.Y, m_BOffset.Y), m_COffset.Y));
            m_OutBox = new Rectangle(t_lowestX, t_lowestY, t_width, t_height);
        }
コード例 #3
0
ファイル: CollisionRectangle.cs プロジェクト: Yuma-Shi/GLhf
 public CollisionRectangle(float a_xOffset, float a_yOffset, float a_width, float a_height, Position a_position)
 {
     m_xOffset = a_xOffset;
     m_yOffset = a_yOffset;
     m_width = a_width;
     m_height = a_height;
     m_position = a_position;
     m_OutBox = new Rectangle((int)(m_xOffset + m_position.getGlobalX()), (int)(m_yOffset + m_position.getGlobalY()), (int)m_width, (int)m_height);
 }