mirror of
https://github.com/liabru/matter-js.git
synced 2025-02-01 18:24:54 -05:00
added catapult demo
This commit is contained in:
parent
0d4a6f4000
commit
419a4300cc
2 changed files with 27 additions and 0 deletions
|
@ -25,6 +25,7 @@
|
||||||
<option value="circleStack">Circle Stack</option>
|
<option value="circleStack">Circle Stack</option>
|
||||||
<option value="pyramid">Pyramid</option>
|
<option value="pyramid">Pyramid</option>
|
||||||
<option value="car">Car</option>
|
<option value="car">Car</option>
|
||||||
|
<option value="catapult">Catapult</option>
|
||||||
<option value="newtonsCradle">Newton's Cradle</option>
|
<option value="newtonsCradle">Newton's Cradle</option>
|
||||||
<option value="wreckingBall">Wrecking Ball</option>
|
<option value="wreckingBall">Wrecking Ball</option>
|
||||||
<option value="avalanche">Avalanche</option>
|
<option value="avalanche">Avalanche</option>
|
||||||
|
|
|
@ -496,6 +496,32 @@
|
||||||
renderOptions.showAngleIndicator = true;
|
renderOptions.showAngleIndicator = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Demo.catapult = function() {
|
||||||
|
var _world = _engine.world;
|
||||||
|
|
||||||
|
Demo.reset();
|
||||||
|
|
||||||
|
var stack = Composites.stack(250, 255, 1, 6, 0, 0, function(x, y, column, row) {
|
||||||
|
return Bodies.rectangle(x, y, 30, 30);
|
||||||
|
});
|
||||||
|
|
||||||
|
var catapult = Bodies.rectangle(400, 520, 320, 20, { });
|
||||||
|
|
||||||
|
World.add(_world, [
|
||||||
|
stack,
|
||||||
|
catapult,
|
||||||
|
Bodies.rectangle(250, 555, 20, 50, { isStatic: true }),
|
||||||
|
Bodies.circle(560, 100, 50, { density: 0.005 }),
|
||||||
|
Constraint.create({ bodyA: catapult, pointB: { x: 390, y: 580 } }),
|
||||||
|
Constraint.create({ bodyA: catapult, pointB: { x: 410, y: 580 } })
|
||||||
|
]);
|
||||||
|
|
||||||
|
var renderOptions = _engine.render.options;
|
||||||
|
renderOptions.showCollisions = true;
|
||||||
|
renderOptions.showVelocity = true;
|
||||||
|
renderOptions.showAngleIndicator = true;
|
||||||
|
};
|
||||||
|
|
||||||
Demo.beachBalls = function() {
|
Demo.beachBalls = function() {
|
||||||
var _world = _engine.world;
|
var _world = _engine.world;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue