Exemple #1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            poly1 = new Polygon(Vector2.Zero, new List <Vector2>()
            {
                new Vector2(100, 0),
                new Vector2(150, 50),
                new Vector2(100, 150),
                new Vector2(0, 100)
            });

            poly2 = new Polygon(new Vector2(80, 80), new List <Vector2>()
            {
                new Vector2(50, 50),
                new Vector2(100, 0),
                new Vector2(150, 150)
            });

            poly3 = new Polygon(new Vector2(400, 200), new List <Vector2>()
            {
                new Vector2(0, 50),
                new Vector2(50, 0),
                new Vector2(150, 80),
                new Vector2(160, 200),
                new Vector2(-10, 190)
            });

            circle = ShapePrimitives.Circle(new Vector2(400, 200), 60, 16);
            rect   = ShapePrimitives.Rectangle(new Vector2(60, 60), new Vector2(120, 120));

            base.Initialize();
        }
Exemple #2
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            IsMouseVisible = true;

            graphics.PreferredBackBufferHeight = 600;
            graphics.PreferredBackBufferWidth  = 800;
            graphics.ApplyChanges();

            world = new Quadtree <Polygon>(new RectangleF(0, 0, 800, 600));

            poly1 = new Polygon(Vector2.Zero, new List <Vector2>()
            {
                new Vector2(25, 0),
                new Vector2(38, 12),
                new Vector2(25, 38),
                new Vector2(0, 25)
            });

            world.Insert(new Polygon(new Vector2(80, 80), new List <Vector2>()
            {
                new Vector2(50, 50),
                new Vector2(100, 0),
                new Vector2(150, 150)
            }));

            world.Insert(new Polygon(new Vector2(400, 200), new List <Vector2>()
            {
                new Vector2(0, 50),
                new Vector2(50, 0),
                new Vector2(150, 80),
                new Vector2(160, 200),
                new Vector2(-10, 190)
            }));

            world.Insert(ShapePrimitives.Circle(new Vector2(600, 200), 60, 10));
            world.Insert(ShapePrimitives.BezelRectangle(new Vector2(60, 60), new Vector2(160, 220), 15));


            world.Insert(ShapePrimitives.Rectangle(new Vector2(620, 200), new Vector2(660, 230)));

            world.Insert(ShapePrimitives.Rectangle(new Vector2(0, 400), new Vector2(30, 430)));
            world.Insert(ShapePrimitives.Rectangle(new Vector2(30, 400), new Vector2(60, 430)));
            world.Insert(ShapePrimitives.Rectangle(new Vector2(60, 400), new Vector2(90, 430)));
            world.Insert(ShapePrimitives.Rectangle(new Vector2(90, 400), new Vector2(120, 430)));
            world.Insert(ShapePrimitives.Rectangle(new Vector2(120, 400), new Vector2(150, 430)));
            world.Insert(ShapePrimitives.Rectangle(new Vector2(150, 400), new Vector2(180, 430)));
            world.Insert(ShapePrimitives.Rectangle(new Vector2(0, 430), new Vector2(30, 460)));
            world.Insert(ShapePrimitives.Rectangle(new Vector2(30, 430), new Vector2(60, 460)));
            world.Insert(ShapePrimitives.Rectangle(new Vector2(60, 430), new Vector2(90, 460)));
            world.Insert(ShapePrimitives.Rectangle(new Vector2(90, 430), new Vector2(120, 460)));
            world.Insert(ShapePrimitives.Rectangle(new Vector2(120, 430), new Vector2(150, 460)));
            world.Insert(ShapePrimitives.Rectangle(new Vector2(150, 430), new Vector2(180, 460)));

            base.Initialize();
        }