The symbol ‘toBottom ’ will be true when the player pressed the spacebar. We then move the block down quickly, but it still needs to happen gradually to be visible. So we use a counter with a small value and subtract the time delta again and again. Each time the counter reaches zero, we move the block downward. If that is not possible, the previous code (Slide Counter) will be executed.
Only when the block does not slide down, we will check the player’s input.
if(toBottom)
{
toBottomTimer -= Time.d();
if(toBottomTimer < 0)
5 {
toBottomTimer = 0.05;
if(canMove(currentBlock, D_DOWN))
{
currentBlock.move(D_DOWN);
10 } else {
toBottom = false;
}
}
} else {
15 handleInput();
}
That concludes this method. All you need to do now is add the create, update and draw methods to the Game State. And then, of course, solve all the mistakes until your application works as it should.