We already got the methods to check for collisions with the pile or the game area. Now we need to check whether it is possible to rotate a block. This is why the method canRotate is created.
In this method, we first create a new block. We do not want to rotate the actual block, but only check if it would be possible. So we call the create function on the new block, with the current block as an argument. Afterwards, the new block will be rotated.
Now we can check if this new block collides with Wall or Pile. The second argument is the direction D_NONE, because we don’t want to check a movement. When one of those methods indicates a collision, the function result is false. Otherwise it will be true.