Tetris (7)

  1. Modify your previous TETRIS program and define a class CTetromino.
  2. A tetromino has the following data members:
    1. unsigned short type_id; // [0..6]
    2. unsigned short pos_x;
    3. unsigned short pos_y;
  3. A tetromino has the following member functions:
    1. The constructor CTetromino() will be invoked with three parameters to initialize data members type_id, pos_x, and pos_y.
      • The default values of these three parameters are all 0.
    2. Draw() - display the tetromino at position (pos_y, pos_x).
      • Note: You should re-use the draw_block() function defined in the previous exercise. (Certainly, you need to slightly modify it to become a member function of the CTetromino class.) This will greatly simplify your task.
    Test your class with this main program. Save your class definition as "tetris.h". Save the main program as "tetris-7a.cpp". Compile the program with
    1. CL /c tetris-7a.cpp /I.
    2. LINK tetris-7a.obj wincursor.obj pdcurses.lib
    Running the program tetris-7a.exe should produce output as follows.
    tetris-7a.png
  4. Add a member function Move(). It has a parameter to indicate the direction of movement. Test your class with this main program. The program should produce output as follows.
    tetris-7b.png