In the previous part we created our project folder and put the assets folder in it. But we didn’t create any code files yet. Let’s add the code files now and build the file hierarchy. Don’t worry if you don’t understand what these files are going to be used for. You don’t need to understand how they are going to be related to one another either. I mean for the time being.
But before we delve into the topic, here’s some info for you.
*****
Book Info
I just published my Kivy book, GUI Programming with Python and Kivy. It’s pretty long (over 800 pages) and comprehensive. And, which also counts, easy to read. The book contains lots of illustrations.
This book covers all the basics that you need to know to start programming GUI applications with Python and Kivy. Throughout the book we are building a GUI application from scratch, a fully functional game using all kinds of tools that Kivy has to offer. It’s our Slugrace project, but covered in a much more in-depth manner.
Each part of the book starts with a theoretical introduction of a topic or idea that we then implement in the project. I assume you have no prior knowledge of the Kivy library, but you should have at least some basic knowledge of the Python programming language, including the object-oriented programming paradigm as this is what we will be using a lot in this book.
The book covers all the basic elements of Kivy that you have to know, like widgets, layouts, Kivy ids and properties, graphics, screens, animation, sound. Finally we’ll deploy the app to Windows. It is pretty comprehensive and after you finish it, I’m sure you’ll be able to create your own awesome GUI apps of any kind, not just games.
I hope you will have at least as much fun reading the book as I had writing it.
As far as this Kivy series is concerned, the following parts will contain the most important elements covered in the book. However, some elements will be presented in a simplified way here on my blog or omitted completely.
____________
If you are interested, you can purchase the book in four versions. Here are the links:
1) ebook – pdf version on my website – in full color
Here you can see the description of the book, sample graphics from the book and the full table of contents.
2) ebook – Kindle version on Amazon – in full color
3) paperback version on Amazon – in black and white
4) paperback version on Amazon – in full color
*****
And Now Let’s Move On…
We’re going to need a couple of files. Most of them will be empty for now and we’ll be filling them in with code as we progress. But creating the file hierarchy with all the files now will give you an idea of how complex our project is going to be.
You can add the files manually or inside Visual Studio Code. I’m going to choose the latter option, so if you want to follow along, launch your VSC editor and open the Slugrace folder from the File menu:
When you open the folder, you can see it only contains the assets folder. This is the folder that we created before. It contains all the assets that we are going to make use of in our game, like visual assets, including the images of the track and the slugs, and audio assets.
Now, let’s add the first Python file, main.py:
Let’s also create the main.kv file:
We’ll also need files to take care of all the different part of our project. They will all come in pairs: a Python file and a kv file. So now repeat the steps above to create the following files:
settings.py, settings.kv
race.py, race.kv
bets.py, bets.kv
results.py, results.kv
widgets.py, widgets.kv
instructions.py, instructions.kv
gameover.py, gameover.kv
This is what it looks like in Visual Studio Code when you’re done:
And here are the files in your project folder:
In the next part we’ll get started with some basic code.