JarWarren / ConflictPhysics

C99 collision and overlap detection

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Conflict Physics

Collision and overlap detection.

I write a lot of small games and most of them don't need a full physics engine. I don't want to mess with acceleration, friction, mass, forces, etc. I just want to tell things where to go and be sure they won't overlap if they're not supposed to.

Conflict lets you do exactly that. Put your bodies where you want them and let it resolve "conflicts".

Features

  • C99 and no dependencies
  • Collisions
  • Detections + callback
  • isOnWall, isOnFloor or isOnCeiling
  • You own your body instances

Usage

Because you own the bodies, you can put them wherever you want (works well with ecs).

#include "conflict_physics.h"
int main(void) {
    CflBody bodies[COUNT];
    bodies[0] = cflCircle(x, y, radius); // your player
    bodies[1] = cflRectangle(x, y, width, height); // the ground
    // etc
    ...
    
    while (yourGameLoop) {
        yourUpdate();
        cflSolve(bodies, COUNT);
        yourDraw();
    }
    
    yourTerminate();
}

Example

  • mkdir build && cd build
  • cmake ..
  • make
  • ./example/ConflictPhysicsExample

About

C99 collision and overlap detection

License:MIT License


Languages

Language:C 92.4%Language:CMake 7.6%