Skip to Content
Creating Apps in Kivy
book

Creating Apps in Kivy

by Dusty Phillips
April 2014
Beginner to intermediate content levelBeginner to intermediate
188 pages
4h 17m
English
O'Reilly Media, Inc.
Content preview from Creating Apps in Kivy

Chapter 12. Advanced Graphics

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.

A Starfield Background

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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Kivy - Interactive Applications and Games in Python

Kivy - Interactive Applications and Games in Python

Roberto Ulloa
Kivy Cookbook

Kivy Cookbook

Hugo Solis
Kivy Blueprints

Kivy Blueprints

Mark Vasilkov

Publisher Resources

ISBN: 9781491947333ErrataSupplemental Content