• Stars
    star
    155
  • Rank 240,864 (Top 5 %)
  • Language
    C
  • License
    MIT License
  • Created over 3 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A lightweight 2D physics engine written in C, for educational purposes.

c-krit/ferox

version badge codefactor badge code-size badge license badge

A lightweight 2D collision detection and physics library written in C.

WARNING: This library is in an early alpha stage, use it at your own risk.

Documentation — Examples — Prerequisites

Features


NOTE: Since this project was made for me to learn how a physics engine works, I am planning to add only the most basic features.

  • Broad-phase collision detection with spatial hashing algorithm
  • Narrow-phase collision detection with SAT (Separating Axis Theorem)
  • 'Sequential Impulse' iterative constraint solver
  • Semi-implicit (symplectic) Euler integrator
  • Support for collision event callbacks

Prerequisites

  • GCC version 9.4.0+
  • GNU Make version 4.1+
  • Git version 2.17.1+
$ sudo apt install build-essential git

Optional

Make sure you have installed raylib 4.0.0+ to compile all examples.

Building

This project uses GNU Make as the build system.

$ git clone https://github.com/c-krit/ferox
$ cd ferox
$ make

You can also build this library as standalone-mode to avoid raylib.h header inclusion and functions that depend on raylib:

$ make BUILD=STANDALONE

Compiling into WebAssembly

Compiling for the Web requires installation of the Emscripten SDK.

$ git clone https://github.com/emscripten-core/emsdk && cd emsdk
$ ./emsdk install latest
$ ./emsdk activate latest
$ source ./emsdk_env.sh

After setting up the environment variables for Emscripten SDK, do:

$ make PLATFORM=WEB

Cross-compiling for Windows

You may need to recompile raylib for Windows before building this library.

$ git clone https://github.com/raysan5/raylib && cd raylib/src
$ make -j`nproc` CC=x86_64-w64-mingw32-gcc AR=x86_64-w64-mingw32-ar OS=Windows_NT

Make sure to set the value of RAYLIB_PATH variable to cross-compile for Windows:

$ make PLATFORM=WINDOWS RAYLIB_PATH=../raylib

References

License

MIT License