For my children Oliver and Amelia.
You are the inspiration in my life.
This book is designed for anyone wanting to learn programming through making fun games. It will also be useful for someone who has already learned the basics of programming and wants to learn how to add fun graphics and create their own games.
It is focused on making the games rather than teaching programming theory. In this book, you're more likely to see code on how gravity affects a missile’s trajectory rather than the most efficient way to search through data. Even then the code is kept simple as games should be more about playability rather than complex physics.
The book starts with a simple text-based game to cover the basics of programming in Python. It then quickly moves on to creating simple graphical games in Pygame Zero. The book introduces object-oriented programming to make it easier to make more complex games. It also explains how you can create your own graphics and sounds.
Throughout the book, you will get to apply the new techniques in a variety of 2D games. As well as some new games, there are some variations on class games including a space shooter game and battleships.
The games are designed to run on the Raspberry Pi, although they can be used on other platforms that support Python 3 with Pygame Zero .
The games you make will be playable and hopefully fun to play. They are only the beginning. If all you ever do is copy the code from this book, then you are only going to learn so much, but by adapting and improving these games, they can become more enjoyable as well as helping you learn more than you ever will from just typing out code that's written down for you. For each of the games, there is a list of suggestions for you to develop the games further.
All the code and resource files used in the book are available from the page to accompany the book at https://www.apress.com/gb/book/9781484256497 .
My family has been very supportive in my maker activities and while writing this book. Thank you to my wife Sarah for her support and to my children Oliver and Amelia who have been a source of inspiration and help while writing the book. Oliver has been particularly helpful in testing the games and giving me feedback, and my daughter’s knowledge of music was a great help while writing about making sounds.
I’d also like to thank the team behind the Raspberry Pi including the Raspberry Pi Foundation and the community that has grown around it. I’ve also been inspired by the work of Nicholas Tollervey who created the Mu editor that is used throughout the book and Daniel Pope who created Pygame Zero, without which the book wouldn’t have been possible.
I’m also grateful to all the support from the team at Apress, to Jessica Vakili for her support in putting the book together, and to Sai Yamanoor for the technical review. There are also many other people who helped to contribute through reviews and getting the book production ready.
is a keen maker and programmer. He has a master’s degree in electronic engineering from the University of Hull and a master’s degree in computer science from Georgia Institute of Technology.
He has over 20 years of experience in the IT industry, working in computer networking, Linux system administration, technical support, and cyber security. While working toward Linux certification, he created the web site www.penguintutor.com . The web site originally provided information for those studying toward certification but has since added information on electronics, projects, and learning computer programming.
Stewart often gives talks and runs workshops at local Raspberry Pi events. He is also a STEM Ambassador and Code Club volunteer, helping to support teachers and children learning programming.
is an embedded systems engineer working for an industrial gases company in Buffalo, NY. His interests, deeply rooted in DIY and open source hardware, include developing gadgets that aid behavior modification. He has published two books with his brother, and in his spare time, he likes to contribute to build things that improve quality of life. You can find his project portfolio at http://saiyamanoor.com .
3.129.211.87