https://github.com/madmann91/thebox
A 2D physics engine in ANSI C
https://github.com/madmann91/thebox
opengl physics-2d
Last synced: 2 months ago
JSON representation
A 2D physics engine in ANSI C
- Host: GitHub
- URL: https://github.com/madmann91/thebox
- Owner: madmann91
- License: mit
- Created: 2018-01-16T17:25:49.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2021-07-08T09:37:34.000Z (almost 5 years ago)
- Last Synced: 2025-08-24T23:32:52.268Z (9 months ago)
- Topics: opengl, physics-2d
- Language: C
- Homepage:
- Size: 72.3 KB
- Stars: 9
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# TheBox
A 2D physics engine in ANSI C.
## Building
mkdir build
cd build
cmake ..
make -j
## Running
TheBox [simulation file]
## Simulation files
Simulation files control the behaviour of the program. The repository contains a simple simulation example in [simulation.txt](simulation.txt).
The syntax is as follows:
- `simulation [nobj] [timestep] [gravity]`: Creates a simulation with `nobj` objects, sets the gravity to `gravity` and the time interval between frames as `timestep`.
- `window [width] [height] [bpp] [scale] [quality]`: Creates a window of size `width`x`height` and `bpp` bits per pixel, sets the view scale to `scale` and rendering quality to `quality` (between 5 and 100).
- `shape [restitution] [friction] box [half width] [half height]`: Creates a box with size 2*`half width`x2*`half height`, and sets its `friction` and `restitution`.
- `shape [restitution] [friction] circle [radius]`: Creates a circle with radius `radius`, and sets its `friction` and `restitution`.
- `object [shape index] [flags] [mass] [x] [y] [angle] ([x speed] [y speed] [angular velocity])`: Creates an object with the shape indexed by `shape index` (starting from 0), the given flags (STATIC=1, SLEEPING=2), `mass`, `position`, and `velocity`.