Beispiel #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)
        {
            switch (currentGameState)
            {
            case GameState.Menu:

                break;

            case GameState.Game:
                ball.Update(gameTime);
                CheckCollision();
                player1.Update(gameTime);
                player2.Update(gameTime);
                KeyboardState newState = Keyboard.GetState();
                if (newState.IsKeyDown(Keys.W))
                {
                    player1.Up(bounds);
                }
                if (newState.IsKeyDown(Keys.S))
                {
                    player1.Down(bounds);
                }

                if (newState.IsKeyDown(Keys.Up))
                {
                    player2.Up(bounds);
                }
                if (newState.IsKeyDown(Keys.Down))
                {
                    player2.Down(bounds);
                }
                break;


            case GameState.Paused:
                break;
            }

            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            // TODO: Add your update logic here
            //animatedSprite.Update();

            base.Update(gameTime);
        }