A world larger than the screen
In both Flood Control and Asteroid Belt Assault, we dealt with game worlds limited to the area of the display window of the game. None of our game objects existed outside the confines of the screen, and, in fact, when we wished to eliminate some objects in Asteroid Belt Assault, we just moved them to an off-screen location, to allow the appropriate code manager to clean them up.
When dealing with a larger game world, we need to make a few adjustments to the way we think about object positions. Instead of simply tracking the location of a sprite on the screen, we will need to track the location of the object in world coordinates:
In this screenshot, the camera points to the upper-left corner of a viewport, within a larger game world. Anything inside the viewport will be visible on the screen, while background areas and objects outside the viewport will not be drawn.
Both the viewport and the game objects can move independently, so we can no longer consider objects...