victorfisac / Physac

2D physics header-only library for videogames developed in C using raylib library.

Home Page:http://www.victorfisac.com/physac

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Make Physac independent

victorfisac opened this issue · comments

Physac is currently dependent of raylib, so functions like DrawPhysicsBodies() and DrawPhysicsContacts() needs to be replaced by some functions to get relevant physics bodies data to make possible to any developer to create its own physics bodies drawing system (I use lines between vertices in my case).

Some of the functions needed are:

  • GetPhysicsBodiesCount() - Count to create a for loop and draw each created body.
  • GetPhysicsBody(int index) - Get each PhysicsBody struct data to access its shape (type, radius, vertices...).

With these functions, anybody can create its own physics body drawing system. But I want to add some other functions to simply it:

  • GetPhysicsVertices(int index) - Returns an array of all vertices final positions (body position + vertex position transformed) in case of PHYSICS_POLYGON, or an array of all vertices final positions to create a circle with 16 divisions (body position + vertex positions based on radius).

By the other hand, some raylib functions used in Physac needs to be reimplemented like GetRandomValue().

Implemented on commits: 13f0b0b, 9fd130b and c994918