Side-view mini golf with moving gator hazards built with pygame. Launch the script to play, or package it as a double-clickable executable.
- Clone or download this repository, then open a terminal in its root (folder containing
golf.pyandrequirements.txt). - Example clone:
git clone <repo-url> mini-golf-game
cd mini-golf-game- Python 3.9 or newer
- pip
- Runtime dependency:
pygame(pinned inrequirements.txt) - Packaging dependency (optional):
pyinstaller
python3 -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python golf.py # Windows may need: python -m golf- Mouse drag on the ball: aim and set power; release to shoot.
- F: fast-forward simulation to where the ball will rest.
- R: reset the ball to the tee (no penalty).
- N / P: next / previous level.
- Enter: advance after sinking a hole.
- Esc: quit.
- Avoid gator mouths; getting chomped adds a penalty stroke.
- Install PyInstaller inside the activated virtual environment:
python -m pip install pyinstaller- Build a windowed, single-file executable:
pyinstaller --name MiniGolf --windowed --onefile golf.py- The build artifacts land in
dist/:- Windows:
dist/MiniGolf.exe(double-click to run) - macOS/Linux:
dist/MiniGolf(binary) and, on macOS, an.appbundle
- Windows:
Re-run the PyInstaller command after code changes. Delete build/ and dist/ if you want a clean rebuild.
- The game is self-contained (no external assets). If the window fails to open on macOS, ensure you are using a Python build with GUI support (python.org installer or recent Homebrew Python).
- For troubleshooting PyInstaller on Windows, run the command from
Developer Command Promptto ensure build tools are on PATH.