A small educational arcade game built with Python and Pygame Zero. Control a pig, collect beetroot to score points, and survive as long as possible without leaving the screen.
This repository accompanies my step-by-step tutorial:
https://edu.cs-htiew.pl/learning-by-games/python/pygame-zero/hungry-pig/
- How to structure a simple Pygame Zero project
- How to use
Actorobjects, images, sounds, and fonts - How to handle keyboard input and movement
- How to implement collision detection and scoring
- How to add game over and restart logic
- Move the pig to collect beetroot.
- Each beetroot increases your score and movement speed.
- If you move outside the game area, it is game over.
Arrow keys: move pigB: toggle bot mode (auto movement toward beetroot)Space: restart after game over
- Python 3.10+ (3.11 recommended)
- Dependencies from
requirements.txt
pip install -r requirements.txtpgzrun main.pyThe included setup.bat builds a Windows executable with PyInstaller:
setup.bat.
|- main.py
|- requirements.txt
|- setup.bat
|- images/
|- sounds/
|- fonts/
- https://kenney.nl/
- https://comigo.itch.io/farm-puzzle-animals
- https://www.zapsplat.com/music/pig-squeal-close-up/
This project is distributed under the terms of the LICENSE file in this repository.
