Пример #1
0
        /// <summary>
        /// Splits the node into 4 subnodes.
        /// </summary>
        private void Split()
        {
            float subWidth = (Bounds.Width / 2);
            float subHeight = (Bounds.Height / 2);
            float x = Bounds.X;
            float y = Bounds.Y;

            Nodes[0] = new QuadTree(Level + 1, new RectangleF(x + subWidth, y, subWidth, subHeight));
            Nodes[1] = new QuadTree(Level + 1, new RectangleF(x, y, subWidth, subHeight));
            Nodes[2] = new QuadTree(Level + 1, new RectangleF(x, y + subHeight, subWidth, subHeight));
            Nodes[3] = new QuadTree(Level + 1, new RectangleF(x + subWidth, y + subHeight, subWidth, subHeight));
        }
Пример #2
0
        public void InitBase()
        {
            VIEWPORT = new ViewportF(0, 0, Config.SCREEN_WIDTH, Config.SCREEN_HEIGHT);
            GAME_AREA_SIZE = new RectangleF(0, 0, Config.SCREEN_WIDTH, Config.SCREEN_HEIGHT);
            ViewportIDMatrix = Matrix.Identity;
            ViewportIDMatrixMirror = new Matrix3x2();
            ViewportIDMatrixMirror.M11 = -1; ViewportIDMatrixMirror.M12 = 0;
            ViewportIDMatrixMirror.M21 = 0; ViewportIDMatrixMirror.M22 = 1;
            ViewportIDMatrixMirror.M31 = 0; ViewportIDMatrixMirror.M32 = 0;

            Entities = new List<BaseEntity>();
            VisibleEntities = new List<BaseEntity>();
            CollidableEntities = new List<BaseEntity>();
            Initialize();
            GameCamera = Camera.GetInstance();
            Quad = new QuadTree(0, GAME_AREA_SIZE);
        }