Example #1
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 (InputWrapper.Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }

            mUWBLogo.Update(InputWrapper.ThumbSticks.Left, Vector2.Zero);
            mBall.Update();
            mBall.Update(Vector2.Zero, InputWrapper.ThumbSticks.Right);

            // "A" to toggle to full-screen mode
            if (InputWrapper.Buttons.A == ButtonState.Pressed)
            {
                mBall = new SoccerBall(mSoccerPosition, mSoccerBallRadius * 2f);

                if (!Game1.sGraphics.IsFullScreen)
                {
                    Game1.sGraphics.IsFullScreen = true;
                    Game1.sGraphics.ApplyChanges();
                }
            }

            // "B" toggles back to windowed mode
            if (InputWrapper.Buttons.B == ButtonState.Pressed)
            {
                if (Game1.sGraphics.IsFullScreen)
                {
                    Game1.sGraphics.IsFullScreen = false;
                    Game1.sGraphics.ApplyChanges();
                }
            }

            // Button X to select the next object to work with
            if (InputWrapper.Buttons.X == ButtonState.Pressed)
            {
                mCurrentIndex = (mCurrentIndex + 1) % kNumObjects;
            }
            // Update currently working object with thumb sticks.
            mGraphicsObjects[mCurrentIndex].Update(
                InputWrapper.ThumbSticks.Left,
                InputWrapper.ThumbSticks.Right);
            base.Update(gameTime);
            base.Update(gameTime);

            mTheGame.UpdateGame(gameTime);
            if (InputWrapper.Buttons.A == ButtonState.Pressed)
            {
                mTheGame = new MyGame();
            }
        }