Page 1 of 1

Creating a physics engine

Posted: Tue Jul 09, 2019 7:15 pm
by hihgsped
Hello,

I'm in the process of creating my own 2d physics engine, but I'm hung up on resolving collisions between objects in my game. Does anyone have any tutorials that explain this process that I could have a link to? I've done a bit of searching but I can't seem to find the right material.

Thanks,
hihgsped

Re: Creating a physics engine

Posted: Wed Jul 10, 2019 12:10 am
by sphyrth
Studying Love2D's Physics Library might help you. especially love.graphics.newFixture, and love.graphics.getDistance.

Re: Creating a physics engine

Posted: Wed Jul 10, 2019 11:00 am
by pgimeno
Depends on whether your shapes are arbitrary or AABB. If you need arbitrary shapes for your objects, collision resolution is going to be a very hard problem, and I recommend sticking to Box2D; however, you can try the HC collision detection library, but last time I checked, it didn't provide collision response, only detection.

For AABBs, things become simple enough for a DIY. I can't recommend any specific tutorial, but look for sources that use 'Minkowski difference' as that simplifies collision resolution a lot.

Re: Creating a physics engine

Posted: Wed Jul 10, 2019 11:48 am
by PGUp
love2d already has it's own physics library, love.physics, if you are struggling with collision detection look this up
https://2dengine.com/?p=intersections

Re: Creating a physics engine

Posted: Wed Jul 10, 2019 1:29 pm
by raidho36
You probably won't be able to do any better than Box2D is already doing, in terms of performance anyway. So if you feel like doing a trigonometry exercise then go ahead, but otherwise you should just learn to use an existing physics engine instead.