# Impulse Engine

Impulse Engine is a small 2D physics engine written in C++ created by Randy Gaul. The engine is intended to be used in an educational manner by allowing others to learn the inner workings of physics engines. The source code of Impulse Engine is filled with comments and is written in as straight-forward a manner as possible.

Features:

• Generalized convex polygons
• Real-time hull creation from any set of points
• Circle and Polygon collision routines using Separating Axis Theorem
• Impulse based collision resolution
• Cross-platform support thanks to whackashoe

If you have any questions feel free to contact Randy at: r dot gaul at digipen dot edu.

Here is a link to the github repository.

Share

## 12 thoughts on “Impulse Engine”

1. Randy Gaul Post author

Wow that looks great! It’s very cool that you ported a Java version of Impulse Engine. It would be great if you could consider using the same license on your port as the Impulse Engine has.

1. CHAOS-THEORY

that’s quiet an honnor, except that i actually wish that you made up all this hard work in AS3; cause am having hard days trying to follow/recreate your work.
also, may i just have a quick way of instant messaging to communicate with you; i would really appreciate that… fb or skype
thanks for your time kind sir

2. Joseph

First, Thank you immensely for crating this project, and to wackashoe for proving the Java version. Now, on the subject of code there is a slight bug/glitch when calculating the penetration of circles to the edges of polygons. I know this is in both versions of code because in your video at around 0:40 the polygon jitters when it contacts the circle on its vertex. A simple fix for this is to recalculate the penetration as the circle’s radius minus the distance from the closest vertex and the center of the transposed bodies:

C++

Java

Obviously this is for the second vertex and two version of this code need to be implemented one for the closest v1 and the other for the closest v2;

This code just needs to be inserted within the code that finds the closest vertex and then calculates the normals.

Thanks again!

3. john

Well done!
By the way, why don’t you make the tutorial at tut+ about the core engine e.g the Body etc. It would be great . . .

1. Randy Gaul Post author

Thanks! Usually it takes a lot of time to write a tuts+ article. How about I just write a new blog post here? :) It would be a big help if you name some more you’d like to hear about, besides just the implementation of Body.

4. john

Thats positive news for me if you mind to write the whole(at least uncovered stuff on tut+) tutorial about your concise and eye-candy implementation.
And how do we integrate all this things to our game system, to sprite(or simple graphics in general), world(at least rectangular platformer world), tile etc(thats maybe and i’m sure time consuming, and can lead to half deadly dizzi-ness syndrome or simply head ache in medical therm).
I dont know, just the idea that insanely hitting my head.
Actually, i have came across to your tutorials at tut+ just about last years.
But, surprisingly i can to figure out how ‘beautifull’ this stuff by now.
I understand why every experienced programmer said that i need to practice and practice again to be good.
And i think he/she’s right, just like physic if Expertise=Knowledge/effort;
since knowledge is infinite, no instant route to master everything but there’s an Expert path as a formula.
Btw, thanks for response and sorry about wasting alot of your time to reply this stupid metaphor suggestion from random amateur folk.

5. john

Edit:
The point is simple game implementation tutorial that using the most feature in your physic engine.
And i think its better than boring API such as javadoc that everybody may get lazy to read(including me at some point). Altought sometimes API documentation its important too. . .
. .but still, BOOKMARKED. .

6. Darren Smith

Randy / Philip,

Thank you for this code! I know this post is over two years old but I’m trying to make a c# port of this and have everything working except for static objects.  I’m mainly  going by the java port.

The Body class’ setStatic method doesn’t seem to function as intended. Instead the static objects act like background polygons where everything passes through them as if they are not there. They are also unaffected by the global gravity force.

If you are still active could you possibly help me with this last problem? I can provide the code if needed. I suspect the problem is easy to fix like a difference in how c# handles the equality operator  or the fact that I’ve changed everything from float to double.

1. Philip Diffenderfer

Darren,

I can take a look at it – just send over your work and I’ll take a gander at it when I have a moment!

Thanks,

Phil