17.2.2 Create and Draw

The create method is easy to complete. Assign values to pos and Type. Then call the method setupSquares. The second create method is a concept we haven’t used before. Here we get a reference to another block as an argument. It is our intention to make a copy of the other block. We do this by copying over each variable from the other block. Because this is the first time you have to create such a method, the complete code is written below. Add this method to your project.

 
void create(C block & other) 
{ 
   T.pos  = other.pos ; 
   T.type = other.type; 
5 
   squares.clear(); 
   FREPA(other.squares) 
   { 
      squares.New().create(other.squares[i].getPos(), other.type); 
10   } 
}  

The draw method is easy enough. You should write it yourself. To draw a block on the screen you just need to call the draw method of all the squares in the container.

At this moment it is already possible to run a test. The create and draw methods already work, so you should check if they do. Run the program with all possible block types and correct your code if something seems off.