A physics-based ball simulation sandbox built with Pygame, featuring realistic physics interactions and engaging gameplay mechanics.
- Realistic Physics: Implements gravity, elastic collisions, and momentum conservation
- Interactive Controls:
- Left-click to spawn or drag balls
- Right-click to toggle force field (push/pull)
- Double-click to clear an area
- Special Effects:
- Golden balls that explode on impact
- Ball merging with visual feedback
- Dynamic color changes based on merges
- Dynamic Spawning System: Automatic ball generation with size variations
- Clone the repository:
git clone https://github.com/CNMengHan/PyphysicsBall.git
cd PyphysicsBall
- Install required dependencies:
pip install pygame
- Run the game:
python main.py
- Spawn Balls: Left-click anywhere on the screen
- Drag Balls: Click and hold on any ball to drag it
- Force Field:
- Hold right-click to activate force field
- Right-click once to toggle between push/pull modes
- Clear Area: Double-click to remove balls in the vicinity
- Watch for Special Balls: Golden balls will explode on impact with the ground
- Built with Python 3.6+ and Pygame 2.0+
- Implements custom physics engine with:
- Velocity-based movement
- Gravity simulation
- Elastic collision detection
- Mass-based interactions
- Force field mechanics
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Pygame community for the excellent gaming framework
- Physics simulation inspiration from various open-source projects
张梦涵 - @CNMengHan
Project Link: https://github.com/CNMengHan/PyphysicsBall