Hi Andrej,
While I can imagine what you try to do here, I would suggest you consider a complete alternative approach.
1. Don't mess arround with strings (in your case characters stored in a string Array - even worse).. So create an "abstraction" of your "board" (game-field whatever you call it) e.g as 2 dimensional Array of booleans (you only have 2 states, don't you? - filled (1) or not (0)).
2. Don't try to do everything in one step. Split your code into different functions/methods. E.g. Create a method for each logical operation you want to support - to "move down", "rotate", ... - then just move arround (or overwrite) the booleans in the "board"-array. In these methods you can consider edge-cases (like rotation isn't possible cause your Piece is "to big" etc.).
3. After you have the "new" board-array (all operations applied) try to "render it" in one step - e.g if you really want to use the RichTextBox (consider BillWoodruff's idea) just rewrite according to your new board.
So you see, if you later decide to make a "real" tetris out of it - with graphics - you will have all the logic in place - just the rendering to change.
Examples (just quick ones to give the idea):
Represent your board as 2d Array
bool[,] board = new bool[20, 13];
- or even better create a board class that handles the "array-logic" internal.
Represent a pice as list of "coordinates" on your board;
struct Coordinate
{
public int X { get; set; }
public int Y { get; set; }
}
A Piece is than a "collection" of coordinates
class Piece
{
public Coordinate[] Coordinates { get; set; }
}
So your Manipulation methods could have signatures like this:
public void MoveDown(Piece piece, bool[,] board) { }
And Rendering could be done like this - just go through all "places" on your board and fill up your RichTextBox, Grid, Labels or whatever - here i used just the console.
static void Render(bool[,] board)
{
for (int iColumn = 0; iColumn < board.GetLength(1); iColumn++)
{
for (int iRow = 0; iRow < board.GetLength(0); iRow++)
{
Console.Write(board[iRow, iColumn] ? "1" : "0");
}
Console.WriteLine();
}
}
So you see how everything sorts itself out to real "objects" in a Tetris game, - the board, the pieces, the positions - this is OOP - and I assume you are learning how to program object orientated with such a toy-project (or homework)...
Happy coding and
Kind regards
Johannes