Programming can be a daunting prospect for anyone dipping their toe into the world of game development.

Python is often revered as an excellent coding gateway as this language prioritizes readability.

What Is Pygame Zero?

retro consoles and games on table

Pygame Zero was created to provide an easier game coding experience for newer Python programmers.

Daniel Pope (“Lord Mauve” onGitHub) set out to create a barrier-free entry for Python beginners.

Installing Pygame Zero

Newer Linux distributions and macOS releases come with Python included.

check python3 version in Linux terminal

For example, check out thishomage to the NES classic, Excite Bike,using Pygame modules.

Are you ready to create your first game?

ThePygame GitHub repositorycontains some great examples of retro games to get you started.

install pygame zero in terminal

To get started with a primer to Pygame Zero, download this minimal project fromGitHub.

The Python code is well documented and the README.md file explains the dependencies you’ll need.

For example, to load theimages/alien.pngfile:

The draw() function tells the computer what to draw on-screen.

Output of code displaying the alien sprite on screen

At that point, it resets the position to the far left.

The process repeats until you terminate the window or pressCTRL + Cin the terminal to end the program.

you’re free to add a fun element by using theon_mouse_down()function.

Run command, code with comments, and Pygame in action

Use this function to check for a mouse click at the same position as the alien sprite.

Print out a suitable response and change the alien sprite to display thealien_hurt.pngimage.

You now have a simple, but functional, target-hitting game.

execute the code with the commandpgzrun intro.py.

Here are some ideas to get those creative juices flowing!

Paperchase

Check out this quick demo of a two-player side-scrolling game with stick figures.

2D Platformer With Fancy Features

This in-depth tutorial lasts about two hours.

After you’ve spent time perfecting your Python and Pygame skills, consider contributing to the open-source project itself.

you’re able to find details in the Pygame Zero GitHub repository.