SHARE
TWEET

Untitled

a guest Jun 19th, 2019 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void CheckForFullLine(int starting_Y)
  2. {
  3.     for (int y = starting_Y; y < frozenCells.GetLength(1); y++)
  4.     {
  5.         for (int x = 0; x < frozenCells.GetLength(0); x++)
  6.         {
  7.             if (!frozenCells[x, y].isFilled)
  8.             {
  9.                 CheckForFullLine(starting_Y + 1);
  10.                 return;
  11.             }
  12.  
  13.             if (x == CELL_COUNT_X - 1)
  14.             {
  15.                 tetrisLinesThisTick++;
  16.                 Debug.Log("lines this tick: " + tetrisLinesThisTick + "on tick: " + tick);
  17.                 ClearLine(y);
  18.             }
  19.         }
  20.     }
  21. }
  22.      
  23. private void Update()
  24. {
  25.     tick++;
  26.     // reset the tetris-lines this tick value:
  27.     tetrisLinesThisTick = 0;
  28.  
  29.     ClearScreen();
  30.     CheckForFullLine(0);
  31.     HandleMovementAndBlockCreation();
  32.     DrawFallingPiece();
  33.     DrawFrozenBricks();
  34. }
  35.      
  36. void ClearLine(int line)
  37. {
  38.     // TODO: Add score
  39.  
  40.     // remove complete line
  41.     for (int x = 0; x < frozenCells.GetLength(0); x++)
  42.     {
  43.         frozenCells[x, line].isFilled = false;
  44.     }
  45.  
  46.     //shift all lines down        // todo: figure out if its a multi-line tetris to give better scores...
  47.     for (int y = line; y < frozenCells.GetLength(1); y++)
  48.     {
  49.         for (int x = 0; x < frozenCells.GetLength(0); x++)
  50.         {
  51.             if (frozenCells[x, y].isFilled)
  52.             {
  53.                 if (y > 0)
  54.                 {
  55.                     frozenCells[x, y].isFilled = false;
  56.                     frozenCells[x, y - 1].isFilled = true;
  57.                 }
  58.             }
  59.         }
  60.     }
  61.  
  62. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top