This project is a simple 2D sandbox simulation built using C++ and the Raylib library. It allows users to interact with a grid of particles and switch between sand and water particles to observe their behavior.
- Grid-based Simulation: The simulation runs on an 800x800 pixel grid divided into 5x5 pixel cells.
- Particle Types: The current implementation supports sand and water particles.
- User Interaction: Users can click on the grid to place particles and press
ENTERto switch between sand and water particles. - Real-time Updates: The simulation updates in real-time, showing how particles interact with each other.
- Raylib: A simple and easy-to-use library to enjoy videogames programming. You can download it from here.
- C++ Standard Library: Includes vector, memory, and random libraries.
-
Clone the Repository:
git clone https://github.com/your-username/2d-sandbox-simulation.git cd 2d-sandbox-simulation -
Install Raylib: Follow the instructions on the Raylib website.
-
Compile the Project:
g++ -o sandbox main.cpp grid.cpp particle.cpp -lraylib -std=c++17 -lpthread -ldl -lrt -lX11
-
Run the Simulation:
./sandbox
- Run the Program: Execute the compiled binary to start the simulation.
- Place Particles: Click on the grid to place the current particle type.
- Switch Particle Type: Press
ENTERto switch between sand and water particles.
- Additional Particles: Add more types of particles such as fire, etc.
- Better Interactions: Improve the interaction logic between different types of particles.
- Optimizations: Optimize the simulation for better performance on larger grids.
Contributions are welcome! Please open an issue or submit a pull request with your improvements.
This project is licensed under the MIT License. See the LICENSE file for more details.
Enjoy the sandbox simulation and have fun experimenting with different particles!