Пример #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()
 {
     gameEngine = new GameEngine();
     base.Initialize();
 }
Пример #2
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();
            kb = Keyboard.GetState();

            if (kb.IsKeyDown(Keys.Back) && kbOld.IsKeyUp(Keys.Back))
                gameEngine = new GameEngine();

            if (kb.IsKeyDown(Keys.Enter) && kbOld.IsKeyUp(Keys.Enter))
                gameEngine = new GameEngine("dog", "muffin");

            if (kb.IsKeyDown(Keys.Space) && kbOld.IsKeyUp(Keys.Space))      //Will cause NullReferenceException in Draw method
                gameEngine = null;

            kbOld = kb;
            base.Update(gameTime);
        }