Cameras and Layers
Louis Salin, Rami Morrar · Apress eBooks · 2021
There are a few improvements you can make to the game in terms of how you organize game objects into the game world. The game places objects directly on the screen by using screen coordinates to position objects and then simply renders the objects in place with no further transformation needed besides a simple scaling effect when some sprite objects are simply too big. While this works reasonably well for a simple game, it adds the complexity of bringing objects into the screen as the game evolves. The choppers and turrets, for example, must be spawned just off screen and then moved into position to create the illusion that the player is continuously moving up through the level. Furthermore, spawning objects off screen becomes more difficult if you add the ability to change the resolution at which your game is rendered. The x = 1,500 axis might be off screen if the screen resolution is 1280 x 720, but not if it is 1920 x 1080.