How to Install Pygame on Windows, macOS, and Linux
Posted by Al Sweigart in pygame
Writings from the author of Automate the Boring Stuff.
I've created Python & Pygame script that lets you walk around the overworld map of the original Legend of Zelda game on the 8-bit Nintendo. There are no monsters or levels or items; it is simply a walking tour. The Link walking sprite animation is implemented by my Pyganim module.
A button is a common user interface (UI) control that is used in many software applications. It seems simple enough: there's a button on the window and you click on it and something happens. But there's a lot of details we should plan out ahead of time. Remember, we want to make a generic button class so that other programmers can use this in their games and programs. Once you've read through the process here, you'll be familiar with how to make your own modules for UI elements.
Here are a couple games I wrote. The first was so popular that I made a sequel.
If you already know a bit of programming and Python, and want to get up to speed on the Pygame 2D game framework, here's a cheat sheet that you can look over. It implements a very short Pygame program covering most of Pygame's basic features.
The Caesar Cipher Wheel is a paper cutout that can be used to perform encryption and decryption in the Caesar Cipher. However, if you don't have a printer but do have Python and Pygame installed, you can use this Caesar Cipher Wheel program to rotate a virtual cipher disk instead.
Draw out horizontal, vertical, or diagonal lines in the same directions that the dot moves. The pattern of the dot's movement becomes longer and longer.
Pygcurse (pronounced "pig curse") is a curses library emulator that runs on top of the Pygame framework. It provides an easy way to create text adventures, roguelikes, and console-style applications. The mascot of Pygcurse is a blue pig with a skull tattoo on its butt.
Here's the source code for a Bejeweled clone called Gemgem, written in Python with Pygame.
Here's a Sokoban ("box pusher") clone called Star Pusher. I've used the graphics from the Planet Cute collection. You'll need Python (2 or 3) and Pygame installed to run it. Just download and unzip the files to the same directory. It comes with 201 levels from David W. Skinner.
I've made a Connect Four AI in Python with Pygame.
I wanted to share this link to a great site with some simple Pygame examples:
There is also a textbook draft called "Introduction to Computer Science Using Python and Pygame" by Paul Vincent Craven.
I've compiled a list of free graphics and sound files that you can use in your games. The chapter on using graphics and sound files with the Pygame library is in Chapter 19 of the "Invent with Python" book.
Made a new game with Pygame. It's called "Squirrel Eat Squirrel", where you move your squirrel around the screen eating the smaller squirrels and avoiding the larger ones. The more squirrels you eat, the larger you grow.
I have a text version of a Connect Four clone done. The AI for it looks ahead two moves, which makes it fairly impossible to beat unless you concentrate.
Welcome to the Code Comments Tutorial for Flippy, an Othello clone. Code Comments is a series of simple games with detailed comments in the source code, so you can see how the game works.
Welcome to the Code Comments Tutorial for Tetromino, a Tetris clone. Code Comments is a series of simple games with detailed comments in the source code, so you can see how the game works.
Welcome to the Code Comments Tutorial for Snakey, a Nibbles clone. Code Comments is a series of simple games with detailed comments in the source code, so you can see how the game works.