Structuring systems-based code
When making a game, it is common to build each component all on its own and not to think about how it will affect the game as a whole. The developer will build a basic framework and then add features as they come along, often resorting to special conditional statements to make the code work without breaking the game. This methodology eventually will start creating bugs in the software requiring more time and effort to fix each one. The bigger the game, the more likely problems will be to arise. It can be an incredibly frustrating experience.
This is where breaking the code into individual systems can really save time and effort. Rather than rewriting elements of code over and over again for each object, we can write self-contained processes into scripts that can be shared. For this game we are going to separate out some of the more basic components, such as gravity and animation, into their own systems.
Creating gravity
The first system we are going to build is...