- Learn Linux
- Learn Electronics
- Raspberry Pi
- LPI certification
- News & Reviews
This is my second professionally published book, published by Apress.
The is a fun way to learn computer programming by creating computer games. This is designed as a book to give you all the skills you need to start programming your own games, from designing the game, creating the graphics, designing sound effects and programming using Pygame Zero.
Here is a quick introduction to the main focus for each of the chapters.
An introduction to the methodology around programming, creating computer games and the Raspberry Pi.
A quick introduction to Python. Designed for those with programming experience from a language other than Python, or as a quick refresher for those that have done some programming in Python before. It introduces the first game which is a text based quiz. This is the only console based game with the rest being designed using Pygame Zero.
An introduction into what Pygame Zero is, along with an introduction to using the Mu editor with Pygame Zero. Create a first graphical game "Compass Game" and learn about how sprites (Actors) can be animated. Learn how to detect collisions in Pygame Zero.
This chapter goes outside of purely programming to investigate what makes a game enjoyable. It gives ideas of what to think about when designing a game. The code then looks at making the compass game more enjoyable through a more appropriate timer and adding obstacles.
To create graphical games then you need to know about how to create the graphics and how to incorporate them into the game. This chapter looks at how you can create graphics using 2D and 3D tools before exporting them for inclusion in a 2D game.
Understand how colors are represented in a computer and how they are used in Pygame Zero. This creates a color changing bouncing ball animation and a color changing which introduces how to handle mouse events in Pygame Zero.
Create a tank based game using Vector Graphics based around basic shapes. Also learn about creating a shell tragectory and how to introduce gravity into a game.
How to record or make sounds and music for use in games. How to use these to create sound effects or to play background music during the game. This chapter introduces a piano / keyboard style game designed for use with the Raspberry Pi touch screen.
Learn about object oriented programming with Python as a way to make code easier to understand. This creates a matching pairs memory game which you can play against the clock to try and find as many pairs as you can.
How to create computer players with an appropriate level of "intelligence". This looks at the memory game and looks at different techniques that can be used to provide a computer competitor instead of the timer. Also creates a new Battleship game using appropriate artificial intelligence to make the game challenging.
Learn additional techniques in Pygame and Pygame Zero. Look at how to create games for the Raspberry Pi Picade and a quick introduction to joysticks / game controllers. Some tips and trips for debugging, including Rubber Duck Debugging.
After following through the book you should have learnt enough skills to adapt the games or create your own games using Pygame Zero.
This video provides an introduction to getting started with Pygame Zero, including creating a first window and creating an animated character on the screen.
How to create vector images in Pygame Zero. Vector images are created from shapes. This uses rectangles, elipses and polygons to create a tank used in a tank battle game. Two tanks then battle it out creating a trajectory for the shells to try and hit their opponent.
Object Orinented Programming is a useful technique for creating any computer programs. This video shows how those techniques can be applied in Python and Pygame Zero to create a matching pairs memory game.
For many games the enjoyment is in playing against a computer opponent which has the right level of ability. It needs to be difficult enough to provide a challenge without being so difficult you always lose. This looks at some techniques of creating an opponent using simple AI.
This isn't complex machine learning which is often associated with AI as that would most likely make most games too difficult to beat. Instead this looks at how the human plays to look at ways that the computer can mimick the same sort of behaviour.
Part 1 uses the same matching pairs memory as the previous video on object-oriented programming, but creating a computer opponent with different levels of difficulty.
Part 2 looks at how you people play the classic Battleship Game to create a computer opponent that provides a good level of difficulty.
For more information on how to play Pygame Zero games using a USB game controller or joystick see the guide: Using a gamepad or joystick on a Raspberry Pi with Python Pygame Zero
The final game is a Space Shooter game. It combines many of the techniques already learned to create a playable game. The video below gives an explanation for some of the additional features used to create the game.
The final video provides an overview showing some of the games that are designed in the book.
You can buy the book direct from Apress. Or from other book sellers. If ordering from an independant seller then quote ISBN 978-1-4842-5649-7.
If you do order through Amazon then please leave a review and let me know what you think. It's very useful to have feedback when working on future books.
* Note the American spelling of color rather than the Britsh English spelling colour which is what I normally use on this website. I live in the United Kingdom and so use British English on my website. The book is however published by an American publisher so has been written using American English for most of the spellings. The code is exactly the same (many programming languages are created using American English, although in some cases Python can be either British or American spellings). Other than a few words spelt differently in the text this is suitable for anyone speaking any variant of English.
Please view the copyright information regarding use of the circuits.