Beispiel #1
0
        //Dictionary<int, cGameObject> entityMap;

        public cEntityPool(cGameScene scene, Vector2f world_size, cPlayer p_player)
        {
            this.pScene    = scene;
            this.worldSize = world_size;
            this.pPlayer   = p_player;
            this.bullets   = new List <cBullet>();
            this.monsters  = new List <cMonster>();

            this.treeMonsters = new cQuadTree <cMonster>(1, scene.World.WorldBounds);
            this.pickups      = new Dictionary <int, cPickupAble>();
            this.spatialGrid  = new cSpatialGrid(worldSize);
            //this.treeBullets = new cQuadTree<cBullet>(1, scene.World.WorldBounds);
        }
Beispiel #2
0
        public void SplitToRects()
        {
            if (level >= MAX_LEVEL)
            {
                return;
            }

            numLevels++;

            float subWidth  = bounds.halfDims.X;
            float subHeight = bounds.halfDims.Y;
            float x         = bounds.topLeft.X;
            float y         = bounds.topLeft.Y;

            pNW = new cQuadTree <T>(level + 1, new cAABB(new Vector2f(x, y), new Vector2f(subWidth, subHeight)));
            pNE = new cQuadTree <T>(level + 1, new cAABB(new Vector2f(x + subWidth, y), new Vector2f(subWidth, subHeight)));
            pSW = new cQuadTree <T>(level + 1, new cAABB(new Vector2f(x, y + subHeight), new Vector2f(subWidth, subHeight)));
            pSE = new cQuadTree <T>(level + 1, new cAABB(new Vector2f(x + subWidth, y + subHeight), new Vector2f(subWidth, subHeight)));
        }
Beispiel #3
0
 public bool Contains(cQuadTree <T> child, T entity)
 {
     //bool b = (cCollision.OverlapAABB(child.Bounds, entity.Bounds));
     //bool b = pChild->GetBounds().AsFloatRect().intersects(pEntity->GetBoundingBox().AsFloatRect());
     return(cCollision.OverlapAABB(child.Bounds, entity.Bounds));
 }