Completing the player's and the background's components
All the game objects are reliant upon or react to the player. For example, the aliens will spawn, chase, and shoot relative to the player's position. Even the background will take its cue for which way to scroll based on what the player is doing. Therefore, as we mentioned previously, it makes sense to get the player working first.
However, remember that using the Entity-Component pattern will mean that some of the components we code for the player will also be used when we implement some other game objects.
Important note
If we hadn't coded the empty component classes before the Transform
class and, subsequently, GameObject
, all these calls to the Transform
class and the context within which these components work might have been harder to understand.
As we code all the player and background components, I will make it clear what is new code and what we coded back in the Coding the player's...