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()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            gameContent  = new GameContent(Content);
            screenWidth  = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
            screenHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
            if (screenWidth >= 2500)
            {
                screenWidth = 2500;
            }
            if (screenHeight >= 1250)
            {
                screenHeight = 1250;
            }
            graphics.PreferredBackBufferWidth  = screenWidth;
            graphics.PreferredBackBufferHeight = screenHeight;
            graphics.ApplyChanges();
            speed1 = gameContent.speed1Sound.CreateInstance();
            speed2 = gameContent.speed2Sound.CreateInstance();
            speed3 = gameContent.speed3Sound.CreateInstance();
            speed4 = gameContent.speed4Sound.CreateInstance();

            int spaceShipX = (screenWidth - gameContent.imgSpaceShip.Width / 4) / 2;
            int spaceShipY = screenHeight - 150;

            spaceShip = new SpaceShip(spaceShipX, spaceShipY, screenWidth, spriteBatch, gameContent);
            shields   = new Shield[3];
            for (int x = 0; x < 3; x++)
            {
                shields[x] = new Shield(screenWidth / 3 * x + screenWidth / 8, spaceShip.Y - 150, spriteBatch, GraphicsDevice);
            }
            alienFleet = new AlienFleet(50, 150, screenWidth, spaceShip.Y, spriteBatch, gameContent);

            ufo = new UFO(0, 60, screenWidth, spriteBatch, gameContent);

            gameBorder = new GameBorder(screenWidth, screenHeight, spriteBatch, gameContent);
        }
Exemplo n.º 2
0
        public void RestartGame()
        {
            livesRemaining = 3;
            aliensKilled   = 0;
            alienFireRate  = 5000;
            firstTime      = false;
            hitBottom      = false;
            level          = 1;
            score          = 0;
            int spaceShipX = (screenWidth - gameContent.imgSpaceShip.Width / 4) / 2;
            int spaceShipY = screenHeight - 150;

            spaceShip = new SpaceShip(spaceShipX, spaceShipY, screenWidth, spriteBatch, gameContent);
            shields   = new Shield[3];
            for (int x = 0; x < 3; x++)
            {
                shields[x] = new Shield(screenWidth / 3 * x + screenWidth / 8, spaceShip.Y - 150, spriteBatch, GraphicsDevice);
            }
            alienFleet = new AlienFleet(50, 150, screenWidth, spaceShip.Y, spriteBatch, gameContent);

            ufo = new UFO(0, 60, screenWidth, spriteBatch, gameContent);

            gameBorder = new GameBorder(screenWidth, screenHeight, spriteBatch, gameContent);
        }