Structuring the Thomas Was Late code
One of the problems that has been getting worse from project to project, despite taking measures to reduce the problem, is how long and unwieldy the code gets. Object-oriented programming (OOP) allows us to break our projects up into logical and manageable chunks, known as classes.
We will make a big improvement to the manageability of the code in this project with the introduction of an Engine
class. Among other functions, the Engine
class will have three private functions. These are input
, update
, and draw
. These should sound very familiar. Each of these functions will hold a chunk of the code that was previously in the main
function. Each of these functions will be in a code file of its own, that is, Input.cpp
, Update.cpp
, and Draw.cpp
, respectively.
There will also be one public function in the Engine
class, which can be called with an instance of Engine
. This function is run
and will be responsible for calling input
, update
, and draw
...