예제 #1
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            ShapeTextures.initGraphics(graphics);
            for (int i = 0; i < 20; i++)
            {
                var  circ = genCircle();
                bool good = true;
                foreach (Primitive p in Circles)
                {
                    if (p.shapeType.Intersects(circ.shapeType))
                    {
                        good = false;
                    }
                }
                if (good == true)
                {
                    Circles.Add(circ);
                }
                else
                {
                    i--;
                }
            }
            Circles.Sort((x, y) => - x.Mass.CompareTo(y.Mass));
            font        = Content.Load <SpriteFont>("mainFont");
            gui         = new GraphicalInterface(graphics.GraphicsDevice, font);
            gui.infoBar = Content.Load <Texture2D>("guiWindow1");

            // TODO: use this.Content to load your game content here
        }
예제 #2
0
        Primitive genCircle()
        {
            float     x      = (float)rand.NextDouble() * screen.Width;
            float     y      = (float)rand.NextDouble() * screen.Height;
            float     dx     = (float)rand.NextDouble() * 5;
            float     dy     = (float)rand.NextDouble() * 5;
            float     radius = rand.Next(10, 60);
            Color     c      = new Color(rand.Next(5, 255), rand.Next(5, 255), rand.Next(5, 255));
            Primitive p      = new Primitive(new Circle(radius, new Vector2(x, y), new Vector2(dx, dy)), ShapeTextures.Circle(radius, c));

            return(p);
        }