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)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back ==
                ButtonState.Pressed || Keyboard.GetState().IsKeyDown(
                    Keys.Escape))
            {
                Exit();
            }

            paddle1.Update(Keyboard.GetState());
            paddle2.Update(Keyboard.GetState());
            ball.Update();

            scoreBoard.Update();



            base.Update(gameTime);
        }
Example #2
0
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            KeyboardState keyboardState = Keyboard.GetState();

            _ball.Update(gameTime);
            _left_paddle.Update(gameTime, keyboardState, _ball);
            _right_paddle.Update(gameTime, keyboardState, _ball);

            if (_ball.GetBounds().Left < _screen_bounds.Left)
            {
                // LEFT GOAL!
            }
            else if (_ball.GetBounds().Right > _screen_bounds.Right)
            {
                // RIGHT GOAL!
            }
            base.Update(gameTime);
        }