0

lately I have been trying to create a 2D platformer engine in C++ with Direct2D. The problem I am currently having is getting objects that are resting against each other to interact correctly after accelerations like gravity have been applied to them.

Right now I can detect collisions and respond to them correctly (I think) and when objects collide they remember what other objects they're resting against so objects can be pushed by other objects (note that there is no bounce in any collisions so when objects collide they are guaranteed to become resting until something else happens). Every time the simulation advances, the acceleration for objects is applied to their velocities (for example vx += ax * t, where t is time elapsed since last advancement).

After these accelerations are applied, I want to check if any objects that are resting against each other are moving at different speeds than their counterparts (as different objects can have different accelerations) and depending on that difference either unlink the two objects so they are no longer resting, or even out their velocities so they are moving at the same speed once again. I am having trouble creating an algorithm that can do this across many resting objects.

Here's a diagram to help explain my problem

https://i.stack.imgur.com/Tb3Kh.png

Tiedye
  • 544
  • 1
  • 4
  • 7
  • You might get more answers at gamedev.stackexchange.com which is focused on game developing. – Memo Oct 16 '13 at 02:15
  • Your explanation seems a bit weird. Why not just code the actual physics calculations and let them behave as they should. You say there's no bounce and that they always stick together but then ask how they will come unlinked but if you just allowed the math to work for you all that would work out automatically. So upon collision you would do math for each collision. When multiple objects are stuck, for simplicity, treat them as an additive object. Unless of course you are dealing with angles and collisions which would/could dislodge them. – ChiefTwoPencils Oct 16 '13 at 03:59
  • Th problem is deciding what objects to treat as an additive object, as some object may accelerate a different speeds. I don't really know what to do, I keep experimenting though. And I'll have a look at gamedev.stackexchange.com. – Tiedye Oct 16 '13 at 13:14

0 Answers0