public void Update(Board gameboard, KeyboardState playerinput) { MovePiece(gameboard); if (Input.ButtonPressed(playerinput, Keys.Z) == true) { RotatePiece(true); if ((gameboard.PieceCollidedX(0) == true || gameboard.TouchedEitherSide() == true) || gameboard.PieceCollidedY() == true) { //Rotate 3 times to get back to the previous position for (int i = 0; i < 3; i++) { RotatePiece(true); } } } }
/// <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) { //Increase game time if (GamePaused == false) { activeTime += (float)gameTime.ElapsedGameTime.TotalMilliseconds; } //Update the game board GameBoard.Update(PlayerInput); //Pause the game if (GameOver == false && Input.ButtonPressed(PlayerInput, Keys.Enter) == true) { GamePaused = !GamePaused; } //Get current keyboard state PlayerInput = Keyboard.GetState(); base.Update(gameTime); }