Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You have already displayed the Tetris Bucket, started dropping the shapes, stopp

ID: 3776238 • Letter: Y

Question

You have already displayed the Tetris Bucket, started dropping the shapes, stopped them at the bottom of the Bucket, dropped another shape from the top, got the user input and moved/rotated the shape in response to the user input. In this assignment, you need to:

1. Determine whether any of the rows are complete.

2. If a row is complete, remove that line and drop all the shapes above the line by one cell.

3. Compute and display the score.

4. Add plenty of narrative comments. Your program must be compilable and executable.

Explanation / Answer

Answer:

As no details about the other assignment on Tetris bucket are given, I assume that you have a working program that manages the drop of shape, its movement and ratation etc. You can use the below mentioned details to perform the tasks in the given assignment:

1. If any row is complete:

I assume that bucket is represented by an m x n array where m is the number of rows and n is the number of columns. An empty cell in the bucket is represented by the presence of ' ' (blank) character. Following function will tell whether a given row is complete:

------------------------------------------

//function to check if a row in bucket is complete.
bool isRowComplete(char** bucket, int row, int n)
{
   bool rowComplete=true; //assume row is complete.
   for(int col=0;col<n;col++)
   {
       if(bucket[row][col]==' ') //check if any cell in row is empty.
       {
           rowComplete=false; //row is empty.
           break;
       }
   }
   return rowComplete;
}

-------------------------------------------------

2. when a row is complete:

--------------------------------------------------------

//function to update a row when it is complete.
void updateRow(char** bucket, int row, int n)
{
   if(isRowComplete(bucket,row,n))
   {
       for(int col=0;col<n;col++)
       {
           bucket[row][col]=bucket[row-1][col]; //drop shapes in cells of upper row
       }
   }
}

--------------------------------------------------

3. Computation of score:

To compute the score, a variable called score can be declared and initialized to zero as below:

---------------------------------

int score=0;

--------------------------------

Whenever user collectes some points, those can be added to the score as:

-----------------------------

score+=points;

------------------------------

4. You can use the explanation given in above points as comments in your program.

Hope this helps you.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote