Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void CheckForFullLine(int starting_Y)
- {
- for (int y = starting_Y; y < frozenCells.GetLength(1); y++)
- {
- for (int x = 0; x < frozenCells.GetLength(0); x++)
- {
- if (!frozenCells[x, y].isFilled)
- {
- CheckForFullLine(starting_Y + 1);
- return;
- }
- if (x == CELL_COUNT_X - 1)
- {
- tetrisLinesThisTick++;
- Debug.Log("lines this tick: " + tetrisLinesThisTick + "on tick: " + tick);
- ClearLine(y);
- }
- }
- }
- }
- private void Update()
- {
- tick++;
- // reset the tetris-lines this tick value:
- tetrisLinesThisTick = 0;
- ClearScreen();
- CheckForFullLine(0);
- HandleMovementAndBlockCreation();
- DrawFallingPiece();
- DrawFrozenBricks();
- }
- void ClearLine(int line)
- {
- // TODO: Add score
- // remove complete line
- for (int x = 0; x < frozenCells.GetLength(0); x++)
- {
- frozenCells[x, line].isFilled = false;
- }
- //shift all lines down // todo: figure out if its a multi-line tetris to give better scores...
- for (int y = line; y < frozenCells.GetLength(1); y++)
- {
- for (int x = 0; x < frozenCells.GetLength(0); x++)
- {
- if (frozenCells[x, y].isFilled)
- {
- if (y > 0)
- {
- frozenCells[x, y].isFilled = false;
- frozenCells[x, y - 1].isFilled = true;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement