Welcome to the Pygame tutorial page. Pygame is a Python module created to make games with python. You can use the pygame 2.0 version with Python 3.8 just installing the dev10 version like this:
pip install pygame==2.0.0.dev10
Pygame is a little bit confusing at first but it is very powerful, completely free and full of examples by the great number of users, so I encorage you to learn it, not only for games but also for guis, presentations, ai etc.
Here I will collect the most interesting posts about my new pygame tutorial that will be costantly updated. This will have an logical sequencial order to make you understand the logic of pygame step by step. Do not forget to bookmark this page and to come back often to see the updates here.
How to install Python
How to install pygame
- 1 Window and surfaces
- 2 Images and background surfaces
- 3.1 Scaling surfaces
1 – How to make windows and surfaces
The screen surface is the main one onto which you will blit (show) images, sprites and … surfaces. Screen is the main surface and other surfaces will be put onto it to show them, to move them in order to rapresent something or make a game. Let’s soon see how to make a window. Go to the link below to see the video about this themes.
2 – Images and background
This time we will blit images on the background, together with simple colored surfaces and we will also color the background of the main surface that can be useful to clear the screen during a game.
3.1 Scaling surfaces
Bonus part 1: Grab a part of a surface with subsurface
Read this good article about pygame sprites.
3.2 – Move the sprite
Finally something’s moving: the sprite. The most simple way to do it is here:
3.3 – Animate and move (flip image)
This time the cat will animate. Just the idle position for the moment.
4. Multiple animation on a single sprite
Here we will try different animations for a single sprite and also a way to modify the speed of the animation. Still a very basic sprite class and no connections with pygame.sprite.Sprite, but that will come soon.
Bonus part 3: grouping sprites
5. Still on movements and animations
Let’s change the way we moved our sprite in the previous lessons.
Bonus: rotating image without losing quality
Bonus 5: perfect collisions
Practical examples: making flappy bird
Flap.py with pygame part 5
Create a clickable label (or a button) with pygame
Create a map editor and a game that uses the map created