I am making a Tetris clone. Is there any way that I can avoid using a 2D array for storing a Tetris block?
EDIT: Suppose I have an array to store an L-shaped piece:
1 0 1 0 1 1
But for the sake of rotation, I do that shape as this:
0 1 0 0 0 1 0 0 0 1 1 0 0 0 0 0
I can do this in either objects or arrays. If I use objects then create four objects for each "square", and I can store the position of each square, and rotate it about the piece's center. But I am finding a better way to optimally perform a rotation on the piece. I believe rotating this array 90 degrees would take O(n^2) time. I try to avoid making rotated copies, and instead rotated on the fly. What algorithm or approach should I use?