http://videobin.org/+70a/8wi.html
ここで何が起こっているかを見ることができ、それを試すためのデモがhttp://student.dei.uc.pt/~drgomes/carry/index.htmlにあります。
そのため、私は Chipmunk JS のデモを使用して、それがどのように機能するかを理解しています ( https://github.com/josephg/Chipmunk-jsを参照)。単純なデモは問題なく開始されますが、その後、物事が狂ったようにジャンプし始め、これを理解しようとしていますが、これまでのところ運がありません.
var radToDeg = 180 / Math.PI;
function PlayState() {
  this.blocks = [];
  this.setup = function() {
    space.iterations = 100;
    space.gravity = new cp.Vect(0, 150);
    space.game = this;
    this.ground = space.addShape(new cp.SegmentShape(space.staticBody, new cp.v(0, 480), new cp.v(640, 480), 0));
    this.ground.setElasticity(0);
    this.ground.setFriction(1);
  };
  this.update = function() {
    space.step(this.dt);
    for (var i = 0; i < this.blocks.length; i++) {
      var block = this.blocks[i];
      block.sprite.x = block.body.p.x;
      block.sprite.y = block.body.p.y;
      block.sprite.angle = block.body.a * radToDeg;
    }
    if (isMouseDown("left")) {
      if (this.canAddBlock) {
        this.canAddBlock = false;
        this.addBlock(mouseX, mouseY);
      }
    } else {
      this.canAddBlock = true;
    }
  };
  this.draw = function() {
    clearCanvas();
    for (var i = 0; i < this.blocks.length; i++) {
      this.blocks[i].sprite.draw();
    }
    // this.ground.sprite.draw();
  };
  this.addBlock = function(x, y) {
    width = 64;
    height = 64;
    var newBlock = new Block(x, y, width, height);
    newBlock.body = space.addBody(new cp.Body(1, cp.momentForBox(1, width, height)));
    newBlock.body.setPos(new cp.v(x, y));
    newBlock.shape = space.addShape(new cp.BoxShape(newBlock.body, width, height));
    newBlock.shape.setElasticity(0);
    newBlock.shape.setFriction(1);
    this.blocks.push(newBlock);
  };
}
desiredFPS = 60;
switchState(new PlayState());
ソースコードは非常に単純ですが、実際にどの位置にあるのかわからないため、地面を作成する方法に疑問があります. キューブはそれを見つけて衝突するようですが。
もう 1 つのソース ファイルは、整理するのに役立つ小さな Block クラスです。
Block = (function() {
  function constructor(x, y, width, height) {
    this.sprite = new Sprite("res/block.png", x, y);
    this.width = width;
    this.height = height;
  }
  constructor.prototype = {
    update: function() {
    }
  };
  return constructor;
})();