A simple Python game where you dodge falling blocks. Built with Pygame. Have fun!
- Player-controlled character
- Randomly spawning falling blocks
- Score tracking
- Virtual environment support
- Easy launcher script
- Modular, well-organized code structure
- Clone or download this repository
- Run the launcher script:
./start_game.sh
-
Create a virtual environment:
python3 -m venv venv
-
Activate the virtual environment:
source venv/bin/activate -
Install dependencies:
pip install -r requirements.txt
-
Run the game:
python main.py
- Launch the game using one of the methods above
- Use LEFT and RIGHT arrow keys to move your character
- Avoid the falling red blocks - they will end your game
- Try to survive as long as possible and build up your score
- After game over:
- Press R to restart
- Press Q to quit
- ← → Arrow Keys: Move left/right
- R: Restart game after game over
- Q: Quit game after game over
dodge_the_blocks/
├── main.py # Main entry point
├── game.py # Game controller class
├── player.py # Player class and logic
├── enemy.py # Enemy class and logic
├── config.py # Game configuration and constants
├── start_game.sh # Launcher script
├── requirements.txt # Python dependencies
├── venv/ # Virtual environment (created after setup)
└── README.md # This file
To work on this project:
- Activate the virtual environment:
source venv/bin/activate - Make your changes to the appropriate module:
config.pyfor game settingsplayer.pyfor player behaviorenemy.pyfor enemy behaviorgame.pyfor game logic
- Test with:
python main.py - Deactivate when done:
deactivate
The game is now organized into logical modules:
config.py: Centralized configuration managementplayer.py: Player movement, drawing, and stateenemy.py: Enemy behavior and collision detectiongame.py: Main game loop and coordinationmain.py: Entry point and pygame initialization
- "Permission denied" on launcher script: Run
chmod +x start_game.sh - Virtual environment not found: Follow the manual setup steps above
- Pygame not installed: Make sure to run
pip install -r requirements.txtin the activated virtual environment - Import errors: Ensure all Python files are in the same directory
MIT License