A Pygame space shooter game that runs in the browser via WebAssembly!
- Python 3.10+
- pip
-
Install Pygbag:
pip install pygbag
-
Navigate to the game folder:
cd eddie-space-runner -
Build and test locally:
pygbag --build main.py
This will:
- Create a
build/web/folder with all the WebAssembly files - Start a local server at
http://localhost:8000 - Open your browser automatically
- Create a
-
Test the game at
http://localhost:8000
- Go to github.com/new
- Name it something like
eddie-space-runnerorspace-game - Make it Public
- Click Create repository
On your local machine:
# Install pygbag if you haven't
pip install pygbag
# Navigate to your game folder
cd eddie-space-runner
# Build for web (without starting server)
pygbag --build main.pyAfter building, your folder structure should look like:
eddie-space-runner/
├── index.html ← Landing page
├── main.py ← Source code
├── README.md
└── build/
└── web/
├── index.html ← Pygbag loader
├── favicon.png
└── ... (wasm files, etc.)
# Initialize git (if not already)
git init
# Add all files
git add .
# Commit
git commit -m "Initial commit - Eddie Space Runner"
# Add your remote (replace YOUR_USERNAME)
git remote add origin https://github.com/YOUR_USERNAME/eddie-space-runner.git
# Push
git push -u origin main- Go to your repository on GitHub
- Click Settings (tab at the top)
- Scroll down to Pages (left sidebar)
- Under Source, select:
- Branch:
main - Folder:
/ (root)
- Branch:
- Click Save
After a minute or two, your game will be live at:
https://YOUR_USERNAME.github.io/eddie-space-runner/
| Action | Key |
|---|---|
| Move | Arrow Keys (↑↓←→) |
| Shoot Up | W |
| Shoot Down | S |
| Shoot Left | A |
| Shoot Right | D |
| Open Shop | TAB |
| Buy Items | Number Keys (1-8) |
| Close Shop | SPACE or ESC |
| # | Item | Cost | Effect |
|---|---|---|---|
| 1 | Heal | 10 gems | +25 health |
| 2 | Speed | 20 gems | +1 movement speed |
| 3 | Shield | 15 gems | Protective shield |
| 4 | Shield Size | 15 gems | Larger shield |
| 5 | Shield Damage | 15 gems | Shield hurts enemies |
| 6 | Drone | 30 gems | Auto-targeting drone |
| 7 | Extra Drone | 20 gems | Additional drone |
| 8 | Drone Damage | 20 gems | +10 drone damage |
- Make sure you've run
pygbag --build main.pysuccessfully - Check that
build/web/folder exists with files - Clear browser cache and try again
- This is a browser security feature
- GitHub Pages should handle this automatically
- If testing locally, use
pygbag main.py(starts proper server)
- Click anywhere on the game canvas first (browser policy)
- Press SPACE to start
- Try Chrome or Firefox (best WebAssembly support)
- Close other tabs
- Reduce browser zoom to 100%
eddie-space-runner/
├── main.py # Game source (Pygame + asyncio)
├── index.html # Nice wrapper page
├── README.md # This file
└── build/web/ # Generated by Pygbag
├── index.html # Pygbag's loader
├── main.py # Copy of your game
├── *.wasm # WebAssembly binary
└── *.js # JavaScript glue code
In main.py, modify:
WIDTH = 1200 # Change width
HEIGHT = 800 # Change heightThen update index.html iframe dimensions to match.
Place .ogg files in the same folder as main.py and load with:
sound = pygame.mixer.Sound("sound.ogg")
sound.play()Place .png files in the same folder and load with:
img = pygame.image.load("sprite.png")Free to use and modify! Have fun! 🚀