๐ฎ Bouncing Balls in a Rotating Hexagon ๐ Overview This Python project simulates two bouncing balls inside a rotating hexagon using Pygame. The balls interact with the hexagon's moving walls, affected by gravity, friction, and realistic collisions.
The project demonstrates: โ Physics Simulation โ Realistic gravity, friction, and bouncing behavior. โ Dynamic Environment โ The hexagon rotates, affecting ball movement. โ Collision Mechanics โ Walls and balls respond naturally to interactions. โ Smooth Animations โ Optimized rendering with Pygame.
๐น Ideal for game physics enthusiasts, Python developers, and those learning Pygame & simulation mechanics.
๐ Features
๐ฏ Realistic Ball Movement โ Gravity & friction slow balls down over time.
๐ Rotating Hexagon โ The walls constantly move, making physics more challenging.
๐ Wall Collisions โ Balls bounce off moving walls with proper angle reflections.
โ๏ธ Optimized Performance โ Smooth animations with vector math.
๐จ Object-Oriented Code โ Easy to modify and extend.
๐ธ Demo Preview
๐ผ๏ธ Screenshot-
๐ ๏ธ Installation 1๏ธโฃ Clone the Repository First, download the project files:
bash Copy Edit git clone https://github.com/YOUR-USERNAME/BouncingBalls-Hex.git cd BouncingBalls-Hex 2๏ธโฃ Install Dependencies Ensure you have Python 3.x installed. Then install Pygame:
bash Copy Edit pip install pygame 3๏ธโฃ Run the Project To launch the simulation, execute:
bash Copy Edit python main.py ๐ฎ How to Play & Experiment The hexagon rotates continuously, affecting ball collisions. Balls bounce dynamically based on the hexagon's movement. Modify gravity, friction, and hexagon speed to experiment with different behaviors! ๐ง Try customizing:
Change ball sizes & colors. Adjust hexagon rotation speed. Modify gravity effects for different results. ๐ License This project is licensed under the MIT License, meaning youโre free to use, modify, and distribute it. See LICENSE for details.
๐ Contributing Want to enhance this project? Feel free to fork the repo and submit pull requests.
bash Copy Edit git checkout -b new-feature git commit -m "Added a cool feature" git push origin new-feature ๐ฉ Contact ๐ฌ Got questions or suggestions? Reach out via:
GitHub Issues โ Report bugs & request features. Email โ zhechevtony@gmail.com
๐ฅ Future Improvements (Next Steps) ๐ Planned Features: โ Add ball-to-ball collisions. โ Implement variable rotation speeds for the hexagon. โ Introduce different ball sizes & behaviors. โ Add a GUI for changing physics settings. โญ Support the Project If you like this project, please star โญ the repository on GitHub! It helps others discover it. ๐