Exemplo n.º 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()
        {
            var width = GraphicsDevice.Viewport.Width;
            _width = width;
            var height = GraphicsDevice.Viewport.Height;
            _height = height;

            // Create a new SpriteBatch, which can be used to draw textures.
            _spriteBatch = new SpriteBatch(GraphicsDevice);
            _background = Content.Load<Texture2D>("star_field_1");
            _logo = Content.Load<Texture2D>("super_massive_logo");
            var playerOneTexture = Content.Load<Texture2D>("bloop-sprite");
            var playerTwoTexture = Content.Load<Texture2D>("brom-sprite");
            _explosionSound = Content.Load<SoundEffect>("explosion");
            _font = Content.Load<SpriteFont>("Segoe");

            var playerOneProjectileTexture = Content.Load<Texture2D>("bloop-projectile");
            var playerTwoProjectileTexture = Content.Load<Texture2D>("andy-projectile");
            GameObjects = new List<GameObject>();
            var centerScreen = new Vector2(width / 2, height / 2);
            var mainPlanetHeight = height * 0.3f;
            _mainPlanet = AddPlanet("Green-Planet", 0.5f, centerScreen, height, 5E14f, 0.47f);
            GameObjects.Add(_mainPlanet);
            //AddPlanet("Rock-Planet-Flat", 0.3f, centerScreen, height, 5E13f, 0.8f);

            // add planets randomly
            //var rand = new Random();
            //for (int i = 0; i < 4; i++)
            //{
            //    Planet planet;
            //    do
            //    {
            //        var origin = new Vector2(rand.Next(width), rand.Next(height));
            //        planet = AddPlanet("Rock-Planet-Flat", 0.15f, origin, height, 1E13f, 0.8f);
            //    }
            //    while(GameObjects.OfType<Planet>().Any(p => p.BoundingSphere.Transform(Matrix.CreateScale(2.0f)).Intersects(planet.BoundingSphere)));
            //    //;
            //    GameObjects.Add(planet);
            //}
            GameObjects.Add(AddPlanet("Rock-Planet-Flat", 0.15f, new Vector2(width * 0.1f, height * 0.1f), height, 5E14f, 0.8f));
            GameObjects.Add(AddPlanet("Rock-Planet-Flat", 0.15f, new Vector2(width * 0.8f, height * 0.2f), height, 5E14f, 0.8f));
            GameObjects.Add(AddPlanet("Rock-Planet-Flat", 0.15f, new Vector2(width * 0.3f, height * 0.7f), height, 5E14f, 0.8f));
            GameObjects.Add(AddPlanet("Rock-Planet-Flat", 0.15f, new Vector2(width * 0.9f, height * 0.6f), height, 5E14f, 0.8f));

            var playerRadius =  (mainPlanetHeight / 2.0f);
            _players = new List<Player> {
                new Player(this, PlayerIndex.One, playerOneTexture, playerOneProjectileTexture, playerRadius, new Vector2(-1, 0), centerScreen, Content.Load<SoundEffect>("bloop-fire")),
                new Player(this, PlayerIndex.Two, playerTwoTexture, playerTwoProjectileTexture, playerRadius, new Vector2(1, 0), centerScreen, Content.Load<SoundEffect>("brom-fire"))
            };
            GameObjects.AddRange(_players);

            //GameObjects.Add(new MovableObject(this, _background, new Vector2(800, 500), 0.1f, 500000000000000));
            //GameObjects.Add(new MovableObject(this, _background, new Vector2(800, 1000), 0.1f, 500000000000000));
            //GameObjects.Add(new MovableObject(this, _background, new Vector2(200, 750), 0.05f, 300000));
        }
Exemplo n.º 2
0
        private Planet AddPlanet(string textureName, float scale, Vector2 origin, int displayHeight, float mass, float boundingSpherePercent)
        {
            var planetTexture = Content.Load<Texture2D>(textureName);
            var planetHeight = (displayHeight * scale);
            var displayScale = planetHeight / planetTexture.Height;

            var planet = new Planet(this, planetTexture, origin, displayScale, mass, boundingSpherePercent);
            return planet;
        }