Skip to main content
main-content

Über dieses Buch

Make fun games while learning to code. Focused on making games rather than teaching programming theory, in this book you're more likely to see code on how gravity affects a missiles trajectory instead of the most efficient way to search through data. Even then the code is kept simple as games should be about playability rather than complex physics. There are links to the official documentation when you need to lookup information that isn't included in the book.
Start with a simple text based game to grasp the basics of programming in Python. Then moves on to creating simple graphical games in Pygame Zero. Not only will you learn object oriented programming to make it easier to make more complex games, you'll also work to create your own graphics and sounds. 3D graphics are a little complex. So we focus on 2D games, including spins on some classic boardgames and arcade games. All the games are designed to run on a Raspberry Pi. They will work on any Raspberry Pi, but will also work on any other computer that supports Python 3 along with Pygame Zero.
The games you make will be playable and hopefully fun to play. And by the end of the book, you can step beyond the provided source code to develop your own unique games and programs.
What You'll LearnCode in PythonGenerate sounds and graphics for 2D gamesGrasp object oriented programming with Pygame Zero
Who This Book Is ForBeginning game developers interested in working with low-cost and easy-to-learn solutions like Pygame Zero and the Raspberry Pi.

Inhaltsverzeichnis

Frontmatter

Chapter 1. Creating Computer Games

Abstract
Writing computer games is a great way to make programming enjoyable, but it does have its disadvantages. The main disadvantage is that to make a working game you need to write a lot of code which takes a lot of time. A full working game is usually too much for a beginner programming book. Fear not, as this book uses worked examples and takes advantage of the simplicity of Python and Pygame Zero to make it as painless as possible. In this book you will create a few different games to illustrate different programming techniques.
Stewart Watkiss

Chapter 2. Getting Started with Python

Abstract
To get started with programming Python, this chapter begins with some basic command-line programming. This will create a simple text-based game that can be played using the keyboard. This is only the beginning; from the next chapter onward, you will be able to create graphical games that are fun to play.
Stewart Watkiss

Chapter 3. Pygame Zero

Abstract
So far, the programs have been text-based, but if we just stuck with text-based games, they would not have the same appeal as graphical ones. The rest of this book is about graphical games, which will be created using Pygame Zero.
Stewart Watkiss

Chapter 4. Game Design

Abstract
Hopefully you've had chance to play the game from Chapter 3 before moving on to this chapter. What did you think of it?
Stewart Watkiss

Chapter 5. Graphic Design

Abstract
The visual graphics are a key part of any game. They are what set the scene, set the tone of the game, and determine whether a game is visually appealing. The level of detail varies greatly between games, from the original pong games which had a simple block bat and ball to modern commercial games which may involve realistic video footage.
Stewart Watkiss

Chapter 6. Colors

Abstract
In Chapter 3 there was a brief mention that there are different ways of defining colors. This chapter will look at the different ways that colors can be used in Pygame Zero. You will also see how the mouse can be used to interact with a program.
Stewart Watkiss

Chapter 7. Tank Game Zero

Abstract
The last few chapters have covered some theory; now you will get a chance to apply some of those techniques into a new game. The game is an artillery battle game called Tank Game Zero – a battle to destroy your enemy’s tank.
Stewart Watkiss

Chapter 8. Sound

Abstract
Adding sound to a game will add an additional dimension and can help bring the game come to life. This can be achieved by adding special effect sounds or adding background music to set the mood. You may also use the sound as a key component in the game.
Stewart Watkiss

Chapter 9. Object-Oriented Programming

Abstract
The programs so far have been primarily using a procedural style of programming. The procedural coding style is a good way to learn programming, but there are benefits to using object-oriented programming, which will be covered next. A useful thing about Python is that it supports many different coding styles, even allowing multiple styles in the same code. You have already been using some object-oriented code when making use of Python modules, including Pygame Zero.
Stewart Watkiss

Chapter 10. Artificial Intelligence

Abstract
Artificial intelligence (AI) in computer games is programming to make the computer behave as though it is intelligent. Typically, this may be showing intelligence behind a character or object that is controlled by the computer.
Stewart Watkiss

Chapter 11. Improvements and Debugging

Abstract
This final chapter will look at a few additional techniques for making improvements to your code. It will also provide some help with debugging when things go wrong. The final game will be a 2D top-down space shooter game. This should help give you the confidence to create your own games using the knowledge acquired from this book.
Stewart Watkiss

Backmatter

Weitere Informationen

Premium Partner

    Bildnachweise