Пример #1
0
 protected override void LoadContent()
 {
     spriteBatch = new SpriteBatch(GraphicsDevice);
     screenSize  = this.Window.ClientBounds;
     rnd         = new Random();
     texture     = Content.Load <Texture2D>("brick");
     arial       = Content.Load <SpriteFont>("arialbd");
     for (int i = 0; i < 2000; i++)
     {
         gameObject go = new gameObject(new Vector2(rnd.Next(0, screenSize.Width), rnd.Next(0, screenSize.Height)), new Vector2(rnd.Next(-10, 10), rnd.Next(-10, 10)), rnd.Next(20, 100), texture, screenSize);
         gameObjs.Add(go);
     }
 }
Пример #2
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            screenSize = this.Window.ClientBounds;
            rnd = new Random();
            texture = Content.Load<Texture2D>("brick");
            arial = Content.Load<SpriteFont>("arialbd");
            for (int i = 0; i < 2000; i++)
            {
                gameObject go = new gameObject(new Vector2(rnd.Next(0, screenSize.Width), rnd.Next(0, screenSize.Height)), new Vector2(rnd.Next(-10, 10), rnd.Next(-10, 10)), rnd.Next(20, 100), texture, screenSize);
                gameObjs.Add(go);
            }

        }
Пример #3
0
        void Insert(gameObject insGo)
        {
            int hashId = ((int)Math.Floor((float)insGo.rect.X / cellSize)) + ((int)Math.Floor((float)insGo.rect.Y / cellSize)) * screenSize.Width / cellSize;

            if (cells.ContainsKey(hashId))
            {
                cells[hashId].Add(insGo);
            }
            else
            {
                cells[hashId] = new List <gameObject> {
                    insGo
                }
            };
            objects[insGo] = hashId;
        }
Пример #4
0
 void Insert(gameObject insGo)
 {
     int hashId = ((int)Math.Floor((float)insGo.rect.X / cellSize)) + ((int)Math.Floor((float)insGo.rect.Y / cellSize)) * screenSize.Width / cellSize;
     if (cells.ContainsKey(hashId))
         cells[hashId].Add(insGo);
     else
         cells[hashId] = new List<gameObject> { insGo };
     objects[insGo] = hashId;
 }