+ 2
Which is more efficient? (OOP)
If you were to make a Tetris program, keeping OOP in mind, would you: 1. Make only one Tetrimino instance, set the values, draw, etc, then change the values then redraw for the next Tetrimino 2. Make a Tetrimino instance for each Tetrimino that falls and destroying them as they stop 3. Something else? Please explain your answers, thank you very much.
2 Answers
+ 3
I think each falling block could be an instance of the tetrimino object, with a specific shape, orientation, and set of coordinates. You cannot destroy it immediately when its fallen, because it may stay on the playing ground for a length of time, in fact some of its building blocks may be eliminated while others might remain longer. So somehow you have to track also the individual squares.
+ 1
I imagine having a single tetromino object that handles the currently falling tetromino and that writes the 4 squares to a big grid after it has fallen is probably easiest for knowing when to clear a line. Afterwards you can destroy the object or just repurpose it for the next tetromino.