Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cnmenghan/pyphysicsball
An interactive physics sandbox built with Pygame, featuring realistic ball physics with gravity, collision, and special effects.
https://github.com/cnmenghan/pyphysicsball
2d-physics 2d-physics-engine ball-physics collision-detection educational-game force-field game-development gravity-simulation interactive particle-system physics-engine physics-simulation pygame python sandbox-game simulation
Last synced: 17 days ago
JSON representation
An interactive physics sandbox built with Pygame, featuring realistic ball physics with gravity, collision, and special effects.
- Host: GitHub
- URL: https://github.com/cnmenghan/pyphysicsball
- Owner: CNMengHan
- License: mit
- Created: 2025-01-10T12:34:49.000Z (27 days ago)
- Default Branch: main
- Last Pushed: 2025-01-11T14:27:45.000Z (26 days ago)
- Last Synced: 2025-01-11T15:34:41.519Z (26 days ago)
- Topics: 2d-physics, 2d-physics-engine, ball-physics, collision-detection, educational-game, force-field, game-development, gravity-simulation, interactive, particle-system, physics-engine, physics-simulation, pygame, python, sandbox-game, simulation
- Language: Python
- Homepage:
- Size: 8.59 MB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PyphysicsBall đŻ
A physics-based ball simulation sandbox built with Pygame, featuring realistic physics interactions and engaging gameplay mechanics.
![License](https://img.shields.io/github/license/CNMengHan/PyphysicsBall)
![Python](https://img.shields.io/badge/python-3.6+-blue.svg)
![Pygame](https://img.shields.io/badge/pygame-2.0+-blue.svg)![Game Screenshot](img/!pyg20250112-061032.png)
## đŽ Features
- **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## đ Installation
1. Clone the repository:
```bash
git clone https://github.com/CNMengHan/PyphysicsBall.git
cd PyphysicsBall
```2. Install required dependencies:
```bash
pip install pygame
```3. Run the game:
```bash
python main.py
```## đŻ How to Play
- **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## đ ď¸ Technical Details
- 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## đ¤ Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
1. Fork the repository
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request## đ License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## đ Acknowledgments
- Pygame community for the excellent gaming framework
- Physics simulation inspiration from various open-source projects## đ Contact
ĺź ć˘Śćśľ - [@CNMengHan](https://github.com/CNMengHan)
Project Link: [https://github.com/CNMengHan/PyphysicsBall](https://github.com/CNMengHan/PyphysicsBall)