Tetris : Effective rotation

Posted by hqt on Game Development See other posts from Game Development or by hqt
Published on 2012-06-19T17:44:39Z Indexed on 2012/06/19 21:25 UTC
Read the original article Hit count: 221

Filed under:

I rotate each piece by rotation formula. More detail, because rotation angle is 90 so :

xNew = y; 

yNew = -x;

But my method has met two problems :

1) Out of box : each type of pieces is fit in square 4x4. (0,0 at under left) But by this rotation, at some case they will out of this box. For example, there is a point with coordinate (5,6) So, please help me how to fit these coordinate into 4x4 box again, or give me another formula for this.

2) at I case : (4 squares at same row or same column), just has two rotations case. but in method above, they still has 4 pieces. So, how to prevent this.

Thanks :)

© Game Development or respective owner

Related posts about rotation