示例#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()
        {
            #region Objects
            astroids = new Astroids();
            players = new Players();
            players.AddPlayers(new Player(new Spacecraft(new Vector2(graphics.GraphicsDevice.Viewport.Width / 2, graphics.GraphicsDevice.Viewport.Height / 2)), 3, new KeyBatch()), new Player(new Vector2(graphics.GraphicsDevice.Viewport.Width / 2 - 100, graphics.GraphicsDevice.Viewport.Height / 2), new KeyBatch(Keys.W, Keys.A, Keys.D, Keys.Q, Keys.E, Keys.T, Keys.Y)));
            #endregion

            #region Visuals
            messages = new Messages();
            explosions = new Explosions();
            #endregion

            #region Game Control
            previousKeyboardState = Keyboard.GetState();
            gameOver = false;
            paused = false;
            level = 1;
            #endregion

            base.Initialize();
        }
示例#2
0
 public void Explode(Explosions explotions)
 {
     life--;
     if (life > 0)
     {
         explotions.AddExplosion(spaceCraft);
         spaceCraft.Visible = true;
     }
 }