This project is a sand simulation game implemented using Pygame and NumPy. The simulation features particles that behave like sand, falling and interacting with obstacles. The particles are rendered with different hues to create a visually appealing effect.
- Sand Particle Simulation: Particles fall, interact with each other, and are affected by obstacles.
- Obstacle Creation: Create obstacles in the simulation by dragging the mouse.
- Dynamic Hue: Sand particles have dynamically changing colors based on their movement.
- Python 3.x
- Pygame
- NumPy
-
Clone the repository:
git clone https://github.com/Bilal-Ahmad102/Sand-Simulation cd Sand-Simulation
-
Install the required libraries:
pip install pygame numpy
Run the any of sand script to start the simulation, example:
python sand_1.py
- Mouse Drag: Create obstacles by dragging the left mouse button.
sand_1.py
: Contains the mainSpace
class that handles the simulation.particles.py
: Contains theParticle
class used for rendering the sand particles.
__init__
: Initializes the simulation window, grids, and particles.make_obstacles
: Placeholder for obstacle creation logic.on_mouse_drag
: Handles mouse drag events to create obstacles.fall
: Manages the falling behavior of sand particles.update_particles
: Updates particle positions and renders them.update
: Updates the simulation state.draw_obstacles
: Draws obstacles on the window.run
: Main loop for running the simulation.
__init__
: Initializes particle attributes.show_sand
: Renders the particle on the given surface.
- Add more particle types with different behaviors.
- Implement advanced obstacle interactions.
- Enhance the user interface with more controls and settings.
Contributions are welcome! Please fork the repository and submit a pull request for any improvements or bug fixes.
- Pygame for the graphics library.
- NumPy for efficient array operations.