Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
edited body
Source Link
user114849
user114849

So, I built a simple physics engine (without rotation as of now)

You can click and then release to create block with velocity.

https://codepen.io/kingofdelphi/pen/vRZvxQ

enter image description here

Now, I want to apply force at the bottom most block. Currently, the block will only slide without affecting the other top blocks.

Now, I can only think of a simple algorithm to make all the top blocks slide when the bottom one slides which goes like this,

  1. shift the current block
  2. find the blocks on top that touch the current block,
  3. recurse each such block and goto step 21

But there are problems with this algorithm(double additions for example, but easy to fix with a boolean flag).

So guys, how do I make all top blocks slide when the bottom one moves?

So, I built a simple physics engine (without rotation as of now)

You can click and then release to create block with velocity.

https://codepen.io/kingofdelphi/pen/vRZvxQ

enter image description here

Now, I want to apply force at the bottom most block. Currently, the block will only slide without affecting the other top blocks.

Now, I can only think of a simple algorithm to make all the top blocks slide when the bottom one slides which goes like this,

  1. shift the current block
  2. find the blocks on top that touch the current block,
  3. recurse each such block and goto step 2

But there are problems with this algorithm(double additions for example, but easy to fix with a boolean flag).

So guys, how do I make all top blocks slide when the bottom one moves?

So, I built a simple physics engine (without rotation as of now)

You can click and then release to create block with velocity.

https://codepen.io/kingofdelphi/pen/vRZvxQ

enter image description here

Now, I want to apply force at the bottom most block. Currently, the block will only slide without affecting the other top blocks.

Now, I can only think of a simple algorithm to make all the top blocks slide when the bottom one slides which goes like this,

  1. shift the current block
  2. find the blocks on top that touch the current block,
  3. recurse each such block and goto step 1

But there are problems with this algorithm(double additions for example, but easy to fix with a boolean flag).

So guys, how do I make all top blocks slide when the bottom one moves?

Source Link
user114849
user114849

Relative motion physics

So, I built a simple physics engine (without rotation as of now)

You can click and then release to create block with velocity.

https://codepen.io/kingofdelphi/pen/vRZvxQ

enter image description here

Now, I want to apply force at the bottom most block. Currently, the block will only slide without affecting the other top blocks.

Now, I can only think of a simple algorithm to make all the top blocks slide when the bottom one slides which goes like this,

  1. shift the current block
  2. find the blocks on top that touch the current block,
  3. recurse each such block and goto step 2

But there are problems with this algorithm(double additions for example, but easy to fix with a boolean flag).

So guys, how do I make all top blocks slide when the bottom one moves?