This project is a particle simulation built in C++ using SDL2 for graphical rendering. It creates visually dynamic patterns by simulating the motion of particles on the screen. The patterns are affected by trigonometric functions and configurable variables, providing opportunities for creative exploration.
- Particle-based simulation with dynamic movement.
- Smooth animations using SDL2.
- Configurable parameters that alter particle motion patterns.
To build and run this project, ensure you have the following installed:
- C++17 or later
- SDL2 (Simple DirectMedia Layer library)
The project consists of the following key files:
main.cpp: Entry point of the application, handles the main simulation loop and rendering.Screen.handScreen.cpp: Responsible for managing the screen and drawing pixels.Swarm.handSwarm.cpp: Manages the collection of particles and updates their state.Particle.handParticle.cpp: Defines the behavior and properties of individual particles.
-
Install SDL2 development libraries:
- On Ubuntu/Debian:
sudo apt-get install libsdl2-dev
- On macOS (using Homebrew):
brew install sdl2
- On Windows:
- Download and install SDL2 from libsdl.org.
- On Ubuntu/Debian:
-
Clone the repository:
git clone <repository-url> cd <repository-folder>
-
Compile the project:
g++ -std=c++17 -o ParticleSimulation main.cpp Swarm.cpp Particle.cpp Screen.cpp -lSDL2 -lm
-
Run the application:
./ParticleSimulation
- The application displays dynamic patterns created by particle movements.
- Changing variable values in
Swarm.cpporParticle.cppcan alter the patterns:- Modify speed and direction in
Particle.cppto control particle behavior. - Adjust color transitions in
main.cppfor different visual effects.
- Modify speed and direction in
- SDL2: For graphics rendering.
- Standard C++ libraries:
iostream,cmath,cstdlib.
Particle::m_speed: Affects particle velocity.Particle::m_direction: Governs the direction of particle motion.- Color variables in
main.cpp: Change the RGB values for particle colors.
This simulation generates vibrant, evolving particle patterns like these:
Lucas Relva
São Paulo, Brazil