Hi, i’m trying to make a Tetris close
I have blocks that fall, and they aren’t allowed to walk out of the array.
Then i wanted to flip one Block with following code:
public void rotateClockwise() {
if (canRotate) {
for (int i = 0; i < 4; i++) {
final int temp = blocks[i].x;
blocks[i].x = -blocks[i].y;
blocks[i].y = temp;
}
}
else
System.out.println("You are not allowed to Rotate here...");
}
But I have no idee how to start, to write a function that validates the flip?
I was thinking if i made a copy of the field and put the block in, that would give an exception but that stops my code all together, i only want to validate it.
For moving Left I used:
blockFits(centrePoint.x, centrePoint.y-1)
and i was abit amazed that the [I] figure 4 blocks on top of eachther didn’t got out of bounds(Because the center is the Second Block?) but that’s another story 8)


