//HandleInput methode voor de TetrisGrid. /// <summary> /// Handles the player input. /// </summary> /// <param name="gameTime">An object with information about the time that has passed in the game.</param> /// <param name="spriteBatch">The SpriteBatch used for drawing sprites and text.</param> /// <param name="LeftMove">When this key is pressed the currently active block is (if possable) moved 1 block to the left in the grid.</param> /// <param name="RightMove">When this key is pressed the currently active block is (if possable) moved 1 block to the right in the grid.</param> /// <param name="RotateCW">When this key is pressed the currently active block is (if possable) rotated 90 degrees Clockwise.</param> /// <param name="RotateCCW">When this key is pressed the currently active block is (if possable) rotated 90 degrees CounterClockwise.</param> /// <param name="GoDown">While this key is pressed the currently active block will move down through the grid at an accelerated speed.</param> public void HandleInput(GameTime gameTime, InputHelper inputHelper, Keys LeftMove, Keys RightMove, Keys RotateCW, Keys RotateCCW, Keys SlamDown, Keys GoDown) { //This part makes sure that the player can move the block to the left and right. if (inputHelper.KeyDown(RightMove) && gameTime.TotalGameTime.Ticks % 6 == 0) //Makes sure the movement is not to fast { Block.MoveRight(); } else if (inputHelper.KeyDown(LeftMove) && gameTime.TotalGameTime.Ticks % 6 == 0) { Block.MoveLeft(); } //The next part is about rotating the blocks. if (inputHelper.KeyPressed(RotateCCW)) { TetrisBlock.RotateCounterClockwiseLegit(Block); } else if (inputHelper.KeyPressed(RotateCW)) { TetrisBlock.RotateClockwiseLegit(Block); } //The following part allows the player to move the block down faster. if (inputHelper.KeyDown(GoDown) && gameTime.TotalGameTime.Ticks % 6 == 0) { Block.MoveDown(); ForceBlockDownwards = true; } else { ForceBlockDownwards = false; } if (inputHelper.KeyPressed(SlamDown)) { Block.SlamDown(); } }