The game is pretty functional and playable right now, especially if you improved it according to the suggestions at the end of the last chapter. However, it is rather ugly and boring to look at. Since I’ll be designing the graphics for this chapter, I can’t promise that it will become less ugly, but I’m pretty sure this chapter will make the game more lively.
Start by jazzing up the background. Since this is a space game, a starfield background seems appropriate. The Internet is an amazing resource; I found a terrific GIMP tutorial that I adapted to create the tileable starfield in Figure 12-1. You can create your own (be creative!), or download mine from the examples on GitHub. Note that I tripled the scale of my version of the image to make it more visible in the print form of this book. This gives it a rather cartoony look. Create a new folder named images in your project folder (at the same level as main.py and energy.kv). Save the file as background.png in that folder.
The next step is to render the image in the app. You could use a Kivy
Image, but that doesn’t give quite the level of control I have in mind. It doesn’t easily allow repeating the texture, nor does it facilitate the scrolling animation effect I have in mind.
Instead, create a new subclass of
Widget in your main.py called
ScrollingBackground. For starters, don’t make the background scroll, but just render a static, repeating texture as described in Example 12-1 ...