Homework: TETRIS (2)

  1. Many students complained that the Screen.pause() function will suspend the program for at least 1 second, and asked whether there is any way to shorten the pause. Actually, Windows provides a function Sleep() which suspends your program in the unit of milliseconds. Therefore, you may Sleep(300) if you want to suspend your program for 0.3 seconds.
  2. Extend your previous homework about TETRIS.
  3. Design a function void draw_block(int n, int y0, int x0) which will draw the nth block at position (y0, x0) in its default color.
  4. Design a function void erase_block(int n, int y0, int x0) which will draw the nth block at position (y0, x0) in COLOR_PAIR(0), which effectively erase the block.
  5. In your main program, use a loop to demonstrate these two fucntions are working correctly.
    
    for (i = 1; i <= 7; i++)
        {
            for (int y = 0; y < 20; y++)
            {
                draw_block(i, y, 2 * i);
                myScreen.redraw();
                Sleep(300); // milliseconds
                erase_block(i, y, 2 * i);
            }
        }