A side-scrolling action game built with Python and Pygame.
- Side-scrolling platformer gameplay
- Player combat with sword and gun mechanics
- Enemy AI with melee combat
- Level system with terrain and collision detection
- Ammunition powerup system
- Python 3.8 or higher
- pygame 2.0.0 or higher
- pygbag 0.8.7 or higher (for web deployment)
- Clone the repository:
git clone <repository-url>
cd PygameSideScroller- Create and activate a virtual environment:
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txtActivate the virtual environment and run:
source venv/bin/activate # On Windows: venv\Scripts\activate
python main.pyOr use the convenience script: ./run.sh
This game can run in a web browser using Pygbag and WebAssembly!
Option 1: Build and test locally
# Build for web
./build_web.sh
# Test locally (requires Python's http.server)
python -m http.server 8000 --directory build/web
# Then open http://localhost:8000 in your browserOption 2: Deploy to GitHub Pages or itch.io
# Build creates a build/web directory
./build_web.sh
# The build/web folder contains all files needed for deployment
# Upload to GitHub Pages, itch.io, or any static hosting serviceOption 3: Quick test with pygbag server
pygbag .
# Opens automatically at http://localhost:8000n/activate # On Windows: venv\Scripts\activate
python Main.py- W / ↑: Jump
- A / ←: Move Left
- D / →: Move Right
- SPACE: Attack (shoot with gun / stab with sword)
- G: Switch weapon (gun/sword)
- F: Toggle sword position (up/down)
- ESC: Quit game
Main.py- Entry point and game initializationGameLoop.py- Main game loop and state managementPlayer.py- Player character logic and controlsEnemy.py- Enemy entity behaviorEnemyManager.py- Enemy spawning and AI managementController.py- Input handlingLevelLoader.py- Level loading from ASCII mapsTerrain.py- Terrain block entitiesGun.py- Gun weapon implementationSword.py- Sword weapon implementationBullets.py- Bullet projectile entityBulletManager.py- Bullet lifecycle managementCollisionManager.py- Collision detection systemConstants.py- Game constants and configuration
Joshua Sonnenberg and Ethan Richardson
CS391 Intro to GameDev with Python and Pygame - Final Project