Friday, June 10, 2016

architecture - How do I build a 2D physics engine?




The most advanced games I've made are a 8-ball pool game made with the physics engine Box2dFlashAS3 and a platform game with levels.


When I did platform games, I've always wished to know how to make an engine, so that I could re-use it. When I see games that have slopes, curved slopes, perfect gravity and real-life physics, I've always wished I knew how to code the engine.


Please suggest techniques and articles for whatever relevant knowledge-base is necessary.



Answer



While I recommend against rolling your own physics engine for anything other than the experience of doing it (just realize you probably should throw it away when you're done -- it's really hard to get all the edgecases and numeric limit/stability issues sorted out, and your time may be much better used by contributing to an existing engine), here are a few resources:


Pool Hall Lessons: Fast, Accurate Collision Detection Between Circles or Spheres discusses circle/circle and sphere/sphere collision.


The N Tutorials are wonderful for a basic understanding of Separating Axis Theorem-based detection and response.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...