Physac is a 2D physics library written in pure C. The engine uses a fixed time-step thread loop to simulate dynamics.
Physac is a 2D physics library written in pure C. The engine uses a fixed time-step thread loop to simulate dynamics. A physics step contains the following phases: reset all physics states, get collision information, apply dynamics, collision solving and position correction. It uses a very simple struct for physic bodies with a position vector to be used in any graphics rendering API.
The header file includes some tweakable define values to fit the results that the user wants with a minimal bad results. Most of those values are commented with a little explanation about their utilities.
Physac uses the following C libraries for memory management, math operations and some debug features:
stdlib.h – Memory allocation [malloc(), free(), srand(), rand()].
stdio.h – Message logging (only if PHYSAC_DEBUG is defined) [printf()].
math.h – Math operations functions [cos(), sin(), fabs(), sqrtf()].
It is independent to any graphics engine and prepared to use any graphics API and use the vertices information (look at examples ‘Drawing’ logic) to draw lines or shapes in screen. For example, this vertices information can be use in OpenGL API glVertex2f().
By the way, I use raylib to create the examples. This videogames programming library is used to handle inputs, window management and graphics drawing (using OpenGL API).