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:

1

blockFits(centrePoint.x, centrePoint.y-1)

and i was abit amazed that the 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

I developed a tetris clone for a class project. this is how I handled that. Everything was based off arrays of single blocks; both the tetris shapes and the dead blocks (the ones that stack at the bottom). When a tetris piece moved or rotated, before it actually moved/rotated, I would move/rotate a mock shape, to determine if any of the blocks making up the shape breached the playing grid or intersected the dead blocks. If the mock shape moved/rotated successfully, then I would rotate the actual shape, otherwise the tetris piece either landed or did not rotate.

see that a tetris piece of blocks has a 2Dimensional area covered by the blocks. if you want to rotate and check for the intersect, do as following ; first calculate the rotation within the game area and then intersect with Rectangle.intersect between you game area and the piece of blocks area. That be quite easy, wouldn't it uh?A validate() meth' must impl these 2 processes and calculate the results (that be the piece graphics bounds) while the painting process waits for a short time to get the validation completed.sheme graphic looks like : PIECE < ----- validate(AffineTransform rotationTX, Rectangle intersect) --------> GameAREA.graphics | ^ ^ drawImage(Rectangle bounds) ---| ------------------------------------------------------------------------------|

lol, I did something similar (ish) once. I am working on a secret Tetris clone (that only a few privileged people have seen) and this is how I handle it: - a PieceTemplate class that stores an array of the block arrangement at all rotations (so that you could handle any of the many rotation systems) - a Piece class with a final PieceTemplate object, direction and position - a Tetrion class with a collides(x,y):boolean method that checks whether the piece collides at the given offset (i.e. if you tried to move at this position relative to where it is now). It could be rewritten to take the direction as an argument too

It allows me to have a really flexible Tetris back end, and the general structure has not changed for a long time. Just about every time I knock together a Tetris clone it has that sort of structure.

Tetris clones seem to be very popular... I already found 3 sources from other people who made the same thing.

btw You might remember that I was here a while ago asking about tile games etc... It's not possible to create a game like that after you got the intro of classes....I learnt a lesson After I'm 100% done with this i will do some more basic games and then i'll try again.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org