示例#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 (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }

            if (Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.Escape))
            {
                this.Exit();
            }



            // TODO: Add your update logic here
            if (!OnMenu)
            {
                myPlayer.Update(graphics, gameTime);
                myLevel.Update(graphics, gameTime);
                myLevel.CheckCollision(myPlayer.MyBall);
            }

            base.Update(gameTime);
        }
示例#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();
            }

            double acc = 0.05;

            // Input the game
            if (Keyboard.GetState().IsKeyDown(Keys.Left))
            {
                myPlayer.ChangeBarSpeed(acc);
            }

            if (Keyboard.GetState().IsKeyDown(Keys.Right))
            {
                myPlayer.ChangeBarSpeed(-acc);
            }

            // TODO: Add your update logic here
            if (!OnMenu)
            {
                myPlayer.Update(graphics, gameTime);
                myLevel.Update(graphics, gameTime);
                myLevel.CheckCollision(myPlayer.MyBalls);
            }

            base.Update(gameTime);
        }