Skip to content

A fully custom written particles simulation written in c

Notifications You must be signed in to change notification settings

Blize/particles-simulation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Partical Simulation

Introduction

This is a simple project I did in C. It is probably not scientifically accurate, but it was fun to make. The program simulates the movement of particles in a 2D space. The particles are affected by gravity and can collide with each other. The program uses the GLFW library to display the particles on the screen, the rest is fully coded by me.

How to install

Unix

  1. Clone the repository
git clone https://github.com/Blize/Particle-Simulation.git
  1. Install the GLFW library
sudo apt-get install libglfw3

or

brew install glfw
  1. Build the project
 cd build
cmake ..
make
./engine

Windows

Good luck! I have no idea how to install the GLFW library on Windows.

How does it work?

If you wanna understand how I strucutred the engine I would suggest you start in the main.c file. From there follow the init() function. After that go through the update() function and finally the render() function.

Also intresting to see is how we handle the States. For that we have the state.h file. Via that we have globally access to our states and header files.

For the Math behind the simulation have a look at the Math file.

Future improvements

  • Implement a more efficient collision detection algorithm, such as a quadtree or spatial hashing, to reduce the number of pairwise comparisons.
  • Add more complex particle interactions, such as friction, air resistance, and particle rotation.

About

A fully custom written particles simulation written in c

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published