The code base in depth
Now that you have the code available, you'll need to familiarize yourself with the code base. Without having a good understanding of the code you want to port, you'll have a much harder time porting it successfully. In this chapter, we're going to walk through each of the C++ class and header files and describe their roles in the application.
Breaking the code into objects
C++ was designed around an object-oriented paradigm, which is what the Tetris code base uses to simplify management of the application. The code base consists of C++ class files
(.cpp
) and header files (.h
) that represent objects within the context of the game. I used the gameplay summary from the What is Tetris? section to extrapolate which objects I needed.
The game pieces (Tetriminos) and playing field (referred to as a well or matrix) are good candidates for classes. Maybe less intuitively, but still just as valid, is the game itself. Classes don't necessarily need to be as concrete as actual objects...