Making it rain
We only need a graphics component. This is fine, just as it was OK to only have an update
component for the level logic. While the RainGraphics
state will change, it is not dependent in any way on the timing of the main game loop or the player’s input. All the changes in state are controlled by the Animator
class instance inside the RainGraphics
class, which has its own internal clock. We will spawn multiple instances of the RainGraphics
class because each instance will cover a small section of the screen. Each RainGraphics
instance will position itself relative to the player and follow the player through the world, giving the impression that it is raining everywhere.
Coding the RainGraphics class
The graphics in the texture atlas look like the following image:
Figure 19.3: Rain From Atlas
I have drawn frames in red around each frame of animation and changed the background from transparent to white. Each frame of animation is 100 pixels by...