This is a template for a game using Pygame-ce that can run in both desktop and browser.
This project is based on Matt Owen's tutorial:
Ninja sprite is from the same author:
Cursor by:
Precision icons created by redempticon - Flaticon
- runs in web (itch.io and GitHub Pages) thanks to pygbag
- implemented fine state machin
- usage of menus pygame-menu (patched - gfxdraw not working in WEB)
- partial mouse support (in menus)
- Tiled map loading pytmx
- Map reloading, scrolling and zooming pyscroll
- map with layers (occlusion and collision)
- custom mouse cursor
- animated sprites
- separation keys from actions
- scene transitions
- automatic screenshots
list key bindings✅- add enemies
- add fog of war and/or line of sight
- add particles system
screenshot of menu not working (showing only part of menu)✅some key events are lost (action is repeated even key is not pressed in menus)✅- continuing game after exiting menu causes loosing player's position on small map (works on grassland though)
- should new map be a new game state?
# create venv
python3 -m venv .venv
# activate it
# on Linux/MacOS
source .venv/bin/activate
# on Windows
.venv\Scripts\activate
# install packages
pip install -r requirements.txtDesktop mode:
cd project
python main.pyBrowser mode:
# from top level folder
pygbag --ume_block 0 projectopen http://localhost:8000/ in browser
use http://localhost:8000#debug to show Python repl terminal in browser - useful for troubleshooting
To itch.io
full instruction here
in short:
pygbag --ume_block 0 --archive projectupload 'build/web.zip' to itch.io or any other hosted site.
full instruction here
