https://github.com/augustocesarperin/chaos-engine
An optimized 2D physics engine built with C++ and SFML
https://github.com/augustocesarperin/chaos-engine
c-plus-plus cpp game-development particle-physics particle-system physics-2d physics-engine sfml
Last synced: 9 months ago
JSON representation
An optimized 2D physics engine built with C++ and SFML
- Host: GitHub
- URL: https://github.com/augustocesarperin/chaos-engine
- Owner: augustocesarperin
- Created: 2025-05-14T02:30:55.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-07-07T06:56:04.000Z (about 1 year ago)
- Last Synced: 2025-07-07T07:46:22.739Z (about 1 year ago)
- Topics: c-plus-plus, cpp, game-development, particle-physics, particle-system, physics-2d, physics-engine, sfml
- Language: C++
- Homepage:
- Size: 33.3 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
🇧🇷 Ler em Português
An engine with some physics and a lot of optimizations. Made for educational and procrastinatory purposes in C++ & SFML.
## Verlet Integration
This program uses Verlet integration for motion calculations. Unlike the Euler method (used in early versions), the Verlet method prevents particles from tunneling through each other at high speeds or when the FPS drops significantly. The system also simulates energy loss in collisions, preventing them from bouncing around ad infinitum.
## Main Optimizations
- Spatial Grid
- Object Pooling
- Structure of Arrays (SoA)
## Controls
**Mouse:**
- Left-click: creates a normal particle
- Right-click: creates a large particle
**Keyboard:**
- `G`: toggles gravity
- `R`: toggles repulsion
- `M`: toggles mouse force
- `N`: switches between attract and repel
- `F`: changes the mouse force style
- `+/-`: adjusts force intensity
- `C`: clears all particles
- `Space`: creates random particles
- `ESC`: bye
## How to Compile
### Windows
Run the file:
```
compile.bat
```
> You need to have [MSYS2](https://www.msys2.org/) with MinGW tools (g++, make, cmake) and SFML installed and in the system's PATH.
### Linux
```sh
sudo apt update && sudo apt install build-essential git cmake libsfml-dev
git clone https://github.com/augustocesarperin/chaos-engine.git
cd chaos-engine
mkdir build && cd build
cmake ..
make
./Chaos
```
Despite being optimized, performance may vary with many particles/interactions. Use at your own risk.
(~Works on my machine~)
### Previous Versions
v0.5
v0.1